摘要: 如$old = array(array('id'=>1,'pid'=>0,'name'=>'第一个' ),array('id'=>2,'pid'=>1,'name'=>'第二个' ) ,array('id'=>3,'pid'=>2,'name'=>'第三个'),);print_r(list_to_tree($old,'id',' 阅读全文
posted @ 2013-02-04 16:27 幻星宇 阅读(467) 评论(0) 推荐(0) 编辑
摘要: function array_intsort($array,$num) {02 $array_right = $array_left = array();03 04 $length = count($array);05 if ($num < $array[0]) {06 array_unshift($array,$num);07 return $array;08 } else {09 for($i=0; $i < $length; $i++) {10 if ($i + 1 < $length) {11 if ($array[$i] < $num && $ 阅读全文
posted @ 2013-02-04 16:03 幻星宇 阅读(247) 评论(0) 推荐(0) 编辑
摘要: //判断是否属手机02function is_mobile() {03$user_agent = $_SERVER['HTTP_USER_AGENT'];04$mobile_agents = Array("240x320","acer","acoon","acs-","abacho","ahong","airness","alcatel","amoi","android",&quo 阅读全文
posted @ 2013-02-04 13:54 幻星宇 阅读(315) 评论(0) 推荐(0) 编辑
摘要: <?php02 /**03 * 安全过滤函数04 *05 * @param $string06 * @return string07 */08 function safe_replace($string) {09 $string = str_replace('%20','',$string);10 $string = str_replace('%27','',$string);11 $string = str_replace('%2527','',$string);12 $string = s 阅读全文
posted @ 2013-02-04 11:55 幻星宇 阅读(187) 评论(0) 推荐(0) 编辑
摘要: <?02 //此文件用于快速测试UTF8编码的文件是不是加了BOM,并可自动移除03 //By Bob Shen04 05 $basedir="."; //修改此行为需要检测的目录,点表示当前目录06 $auto=1; //是否自动移除发现的BOM信息。1为是,0为否。07 08 //以下不用改动09 10 if ($dh = opendir($basedir)) {11 while (($file = readdir($dh)) !== false) {12 if ($file!='.' && $file!='..' 阅读全文
posted @ 2013-02-04 11:53 幻星宇 阅读(955) 评论(0) 推荐(0) 编辑
摘要: [代码] [PHP]代码view source01 <?php02 define('ROOT','D:/Program Files/www/test/');03 class Files_Tool{04 protected static $allowExt=array('.jpg','.jpeg','.png','.gif','.bmp','.svg','.chm','.pdf','.zip','.rar&# 阅读全文
posted @ 2013-02-04 11:52 幻星宇 阅读(155) 评论(0) 推荐(0) 编辑
摘要: [代码] [PHP]代码001<?php002/************003*汉字转换拼音Class005*************/006class pin{007function Pinyin($_String, $_Code='gb2312'){008010"|chai|chan|chang|chao|che|chen|cheng|chi|chong|chou|chu|chuai|chuan|chuang|chui|chun|chuo|ci|cong|cou|cu|".011"cuan|cui|cun|cuo|da|dai|dan|d 阅读全文
posted @ 2013-02-04 11:46 幻星宇 阅读(1044) 评论(0) 推荐(0) 编辑
摘要: [代码] [PHP]代码1function extract_emails_from($string) {2//加入对#的判断,这个你懂的^_^ http://blog.ddian.cn3preg_match_all("/[\._a-zA-Z0-9-]+(@|#)[\._a-zA-Z0-9-]+/i", $string, $matches);4return $matches[0];5} 阅读全文
posted @ 2013-02-04 11:45 幻星宇 阅读(232) 评论(0) 推荐(0) 编辑
摘要: [代码] [PHP]代码01$language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2);02//获取访客语言,是HTTP头信息的ACCEPT_LANGUAGE的前两个字符03// http://blog.ddian.cn04if($language != 'zh'){05//zh是中文,包括zh-CN简体中文和zh-TW正体中文06header("Location: /yourpage.html");07//这句代码是将用户转向到根目录的yourpage.html这里08exit;09// 阅读全文
posted @ 2013-02-04 11:38 幻星宇 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 网站要做个每天定时更新的功能,可老板要求不能在服务器上长期打开一个页面,这样也不是我所期望的。这就想到了windows的task功能。来看看下面的操作:1、首先将“F:\PHP\php.exe F:\www\htdocs\a.php”写入到”new_zw.tast“(bat文件名可以自己取)文件中。2、”控制面板“=》”任务计划“=》”添加任务计划“,选择添加自己的新建的”new_zw.tast“文件,然后根据自己需要进行配置。(注意:那个密码要填写你对应的用户名的密码) 阅读全文
posted @ 2013-02-04 11:30 幻星宇 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 一.首先是PHP网页的编码1.php文件本身的编码与网页的编码应匹配a.如果欲使用gb2312编码,那么php要输出头:header(“Content-Type: text/html; charset=gb2312"),静态页面添加<meta http-equiv="Content-Type" content="text/html; charset=gb2312">,所有文件的编码格式为ANSI,可用记事本打开,另存为选择编码为ANSI,覆盖源文件。b.如果欲使用utf-8编码,那么php要输出头:header(“Content-T 阅读全文
posted @ 2013-02-04 11:27 幻星宇 阅读(493) 评论(0) 推荐(0) 编辑
摘要: 本文将介绍Php 生成静态html文件的三种方法 。1,下面使用模版的一个方法!<?php $fp = fopen ("templets.html","a"); if ($fp){ $fup = fread ($fp,filesize("templets.html")); $fp2 = fopen ("html.shtml","w"); if ($fwrite ($fp2,$fup)){ $fclose ($fp); $fcolse ($fp2); die ("写入模板成功&qu 阅读全文
posted @ 2013-02-04 11:00 幻星宇 阅读(1419) 评论(0) 推荐(0) 编辑