随笔分类 -  PHP-Collection

收藏PHP相关的库、函数
exIconv()支持数组递归转码
摘要:/** * 支持数组方式递归转换的iconv * @author Wilson Zeng | wilsonzeng@ppstream.com | jackzcs@gmail.com * @param unknown_type $inCharset * @param unknown_type $ou... 阅读全文
posted @ 2013-03-05 14:14 重生 阅读(445) 评论(1) 推荐(0)
格式化显示
摘要://格式化为:{n}GB{n}MB{n}KB的样式function formatByteSize($bytes) { $format = $bytes . 'B'; foreach (array(1 => 'KB', 2 => 'MB', 3 => 'GB') as $exp => $unit) { $base = pow(1024, $exp); if ($bytes > $base) { $format = number_format($bytes / $base, 2) . $unit; con 阅读全文
posted @ 2012-11-21 11:13 重生 阅读(265) 评论(0) 推荐(0)
【转】判断某字符串是否是UTF-8编码
摘要:1 //参考 http://w3.org/International/questions/qa-forms-utf-8.html 2 function is_utf8($string) { 3 return preg_match('%^(?: 4 [\x09\x0A\x0D\x20-\x7E] ... 阅读全文
posted @ 2012-02-29 18:14 重生 阅读(479) 评论(0) 推荐(0)
JS相关
摘要:/** * wrap javascript codes with a html-tag * @author Wilson Zeng */function js($script){ return '<script type="text/javascript">'."\n".$script."\n".'</script>'."\n";}/** * wrap javascript codes with a html-tag & history back * 阅读全文
posted @ 2012-01-17 13:57 重生 阅读(168) 评论(0) 推荐(0)
数组操作
摘要:/** * Like end(),return the first element of an array * @author Wilson Zeng */function first($stack){ if(is_array($stack)){ reset($stack); return current($stack); }else{ return $stack; }} 阅读全文
posted @ 2012-01-17 13:31 重生 阅读(115) 评论(0) 推荐(0)
exforce_download() -- 对CI中force_download()增强后的函数(不依赖CI)
摘要:/** * Enhanced force_download, can accept file in server * @author Wilson Zeng * @param $filename | The name that will use as the download file's nam... 阅读全文
posted @ 2012-01-17 13:30 重生 阅读(1225) 评论(0) 推荐(0)
关于远程操作的函数
摘要:/** * Enhanced file_get_contents, use curl to fetch remote file * @param $file * @author Wilson Zeng */function ex_file_get_contents($file){ //if is ... 阅读全文
posted @ 2012-01-17 13:28 重生 阅读(295) 评论(0) 推荐(0)
exTrim() -- Enhanced trim() to support array
摘要:/** * Enhanced trim() to support array * @author Wilson Zeng */function exTrim($mixed, $removeEmptyString = FALSE){ if(is_array($mixed)){ foreach($mixed as $index => &$item){ $item = exTrim($item); if($removeEmptyString && $item === ''){ array_splice($mixed, $index, 1); ... 阅读全文
posted @ 2012-01-17 12:05 重生 阅读(219) 评论(0) 推荐(0)