수학관련 함수
/** 소수검사 */ function chkPrime(n) { if(n == 1) {return false;}; for(i=2; i
- Javascript
- · 2009. 1. 8.
/** 소수검사 */ function chkPrime(n) { if(n == 1) {return false;}; for(i=2; i
/****************************** scandir() : php5에서 디렉토리 목록 반환 ******************************/ if(function_exists("scandir") == false) { function scandir($d,$o = 0) { if(!is_dir($d)) { return false; } $arr = Array(); if ($dh = opendir($d)) { while (($e = readdir($dh)) !== false) { $arr[] = $e; } closedir($dh); } if($o == 1) { return rsort($arr,SORT_STRING); } return sort($arr,SORT_STRING);; } }
/************************************************ 퍼센트 ************************************************/ function GetPercent($val,$total) { if($val) { return ($val/$total)*100; }else { return 0; } } /************************************************ 전체 값에서 퍼센트에 해당하는 값을 뺀 값 ************************************************/ function GetDepercentRemain($per,$total) { return $total-(($per/100)*$total)..
function array2cookie($arr,$cname,$ctime=0,$cpath="/",$cdomain="") { //$_arr = arrayWalk($arr,"urlencode"); $_arr = serialize($arr); setcookie("$cname",$_arr,$ctime,"$cpath",$cdomain); unset($_arr); } function arrayWalk($arr,$func) { switch(!is_array($arr)) { case true: return $arr; break; } foreach($arr as $key=>$val) { switch(is_array($val)) { case true: $arr[$key] = arrayWalk($val,$func); bre..
if(!function_exists("stripos")) { function stripos($srch,$str) { return strpos(strtolower($srch),strtolower($str)); } } function make_pattern_str_ireplace(&$pat, $key) { $pat = '/'.preg_quote($pat, '/').'/i'; } if(!function_exists('str_ireplace')){ function str_ireplace($search, $replace, $subject){ if(is_array($search)){ array_walk($search, 'make_pattern_str_ireplace'); } else{ $search = '/'.pr..