2012年8月2日

php实现繁简转换

摘要: class Big5_GB2312_Transfer{ private $utf8_gb2312; private $utf8_big5; public function __construct(){ $this->utf8_gb2312 = file_get_contents('./gb2312.map'); $this->utf8_big5 = file_get_contents('./big5.map'); } public function c2t($str) { $str_t = ''; ... 阅读全文

posted @ 2012-08-02 16:15 ianarfa 阅读(400) 评论(0) 推荐(0) 编辑

php实现按utf8编码对字符串进行分割

摘要: <?phpfunction mb_str_split( $string ) { # Split at all position not after the start: ^ # and not before the end: $ return preg_split('/(?<!^)(?!$)/u', $string ); } ?> 阅读全文

posted @ 2012-08-02 15:54 ianarfa 阅读(266) 评论(0) 推荐(0) 编辑

php遍历文件夹(或文件)

摘要: <?phpfunction read_dir($dir){ $arr = array(); $arr[] = $dir; if (is_dir($dir)){ $dh = opendir($dir); if (!$dh){ return $arr; } while ($file = readdir($dh)){ if ($file == '.' || $file == '..'){ continue; } ... 阅读全文

posted @ 2012-08-02 15:52 ianarfa 阅读(170) 评论(0) 推荐(0) 编辑

php实现按单词对字符串进行翻转

摘要: 1 <?php 2 // 根据起始和结束位置翻转字符串 3 function reverse_str(&$str,$start,$end){ 4 $middle = intval(($start+$end) / 2); 5 for ($head=$start;$head<=$middle;$head++){ 6 $tail = $end - $head + $start; 7 if ($str[$head] == $str[$tail]){ 8 continue; 9 }10 $temp ... 阅读全文

posted @ 2012-08-02 15:34 ianarfa 阅读(226) 评论(0) 推荐(0) 编辑

导航