Time of Update: 2016-07-25
/* com_create_guid()是php5版本支援的功能,對於不支援的版本,可以自己進行定義;*/function guid(){ if (function_exists('com_create_guid')){ return com_create_guid(); }else{ mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
Time of Update: 2016-07-25
/*** 去除數組中重複值的函數* by bbs.it-home.org*/function array_assoc_unique($arr, $key) { $tmp_arr = array(); foreach($arr as $k => $v) { if(in_array($v[$key], $tmp_arr)) { unset($arr[$k]); } else { $tmp_arr[] = $v[$key];
Time of Update: 2016-07-25
CREATE TABLE IF NOT EXISTS `downloads` ( `id` int(6) unsigned NOT NULL AUTO_INCREMENT, `filename` varchar(50) NOT NULL, `savename` varchar(50) NOT NULL, `downloads` int(10) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY
Time of Update: 2016-07-25
/* 24小時柱狀圖 作者:taokey QQ:29611705* 編輯:bbs.it-home.org*/ function h24($str){ $hour = explode(",",$str); $hmax = max($hour); $ppix = 150/$hmax; //計算柱狀圖高度 $h0 = 190-$hour[0]*$ppix; $h1 = 190-$hour[1]*$ppix; $h2 =
Time of Update: 2016-07-25
DEFINE("CACHE_DIR","/tmp/jpgraph_cache/");' DEFINE("TTF_DIR","/usr/X11R6/lib/X11/fonts/truetype/");複製代碼Windows系統改為: DEFINE("CACHE_DIR","c:/apache/htdocs/ jpgraph_cache/");' DEFINE("TTF_DIR","c:/windows/fonts");複製代碼注意事項:
Time of Update: 2016-07-25
/** * 數組轉編碼 * @param array $array 待轉碼數組 * @param String $inCharset 原編碼 * @param String $outCharset 轉換後的編碼 * @return $array 轉換後的數組 * @site:bbs.it-home.org */private function arrayCoding ($array, $inCharset, $outCharset) { if (!is_array($array))
Time of Update: 2016-07-25
function tranTime($time) { $rtime = date("m-d H:i",$time); $htime = date("H:i",$time); $time = time() - $time; if ($time $str = '剛剛'; } elseif ($time $min = floor($time/60); $str = $min.'分鐘前';
Time of Update: 2016-07-25
//url形式function embSwfWithUrl(dataurl,divcon){ var params = { "wmode": "transparent", "menu": "false", "scale": "noScale", "allowFullscreen": "false", "allowScriptAccess": "always", "bgcolor": "#c0c0c0"
Time of Update: 2016-07-25
//函數名: compress_html//參數: $string//傳回值: 壓縮後的$string//by bbs.it-home.orgfunction compress_html($string) { $string = str_replace("\r\n", '', $string); //清除分行符號 $string = str_replace("\n", '', $string); //清除分行符號 $string = str_replace("\t", '',
Time of Update: 2016-07-25
#!/bin/awk -f #運行前 BEGIN { FS = " "; count = 0; } #運行中 { iparr[count ++] = $0; } #運行後 END { printf(" printf("$iparr = array(\n"); for (i = 0; i printf("'%s' => '%s',\n", iparr[i], iparr[i]); }
Time of Update: 2016-07-25
/*** 字串 截取函數* by bbs.it-home.org*/function msubstr($str, $start, $len) { $tmpstr = ""; $strlen = $start + $len; for($i = 0; $i if(ord(substr($str, $i, 1)) > 0xa0) { $tmpstr .= substr($str, $i, 2); $i++; }
Time of Update: 2016-07-25
/*** JpGraph類產生柱狀圖* by bbs.it-home.org*/$datay=array(); //縱座標資料 $datax=array(); //橫座標資料 foreach ($usernums as $key => $value){ $datay[] = $value; $datax[] = $userids[$key]; } require_once (‘jpgraph-3.0.7/jpgraph/jpgraph.php'); require_once
Time of Update: 2016-07-25
number_format(288); 輸出 288 number_format(365,2); 輸出 365.00 number_format(365000000,3,".") (將數字 365000000 保留3位小數,小數點用"."表示) 輸出: 365,000,000.000 number_format(365000000,2,".","*") (將數字 365000000 保留2位小數,小數點用"."表示,千位分隔字元用"*"表示) 輸出:
Time of Update: 2016-07-25
// 快速的判斷$a數組是否是$b數組的子集 $a = array(135,138); $b = array(135,138,137); 複製代碼實現方法:方法1,for迴圈遍曆 $flag = 1; foreach ($a as $va) { if (in_array($va, $b)) { continue; }else { $flag = 0; break; } } if ($flag) {
Time of Update: 2016-07-25
輸入您註冊的電子郵箱,找回密碼: 複製代碼當使用者輸入完郵箱並點擊提交後,jQuery先驗證郵箱格式是否正確,如果正確則通過向後台sendmail.php發送Ajax請求,sendmail.php負責驗證郵箱是否存在和發送郵件,並會返回相應的處理結果給前台頁面。jQuery代碼: $(function(){ $("#sub_btn").click(function(){ var email = $("#email").val(); var preg =
Time of Update: 2016-07-25
/*** php 柱狀圖 imagefilledrectugle函數用例* by bbs.it-home.org*/function createImage($data,$twidth,$tspace,$height){ header("Content-Type:image/jpeg"); $dataname = array(); $datavalue = array();//data裡面的值 $i = 0; $j = 0; $k = 0; $num =
Time of Update: 2016-07-25
CREATE TABLE IF NOT EXISTS `votes` ( `id` int(10) NOT NULL AUTO_INCREMENT, `likes` int(10) NOT NULL DEFAULT '0', `unlikes` int(10) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO `votes` (`id`,
Time of Update: 2016-07-25
/*** 取得網站的完整地址* by bbs.it-home.org*/function getRootUrl(){ $name = ''; if ( isset($_SERVER['HTTP_HOST']) ){ $name = $_SERVER['HTTP_HOST']; }else{ $name = $_SERVER['SERVER_NAME']; } if ( strpos($name,':') === false && $_SERVER['SERVER_PORT'
Time of Update: 2016-07-25
/*** smarty模板引擎中使用php函數* by bbs.it-home.org*/require 'libs/Smarty.class.php'; $smarty=new Smarty; $smarty->compile_check=true; $smarty->debugging=true; $str1='testtesttesttest'; $str2='this is a'; $str3='指令碼 學堂
Time of Update: 2016-07-25
$dataArray="";$nameArray="";$dataArray = "10,20,30,40,50";$nameArray = "一月,二月,三月,四月,五月";echo "";?>$dataArray="";$nameArray="";$dataArray = "10,20,30,40,50,20,30,40,50,20,30,40,50";$nameArray = "一月,二月,三月,四月,五月,二月,三月,四月,五月,二月,三月,四月,五月";echo