Loading...

Archive for June, 2005

函数巧妙地运用了正则表达式, 用起来很方便, 就像 substr 的用法一样, 可以正向截取也可反相截取, 思路值得学习 :)

PLAIN TEXT >> PHP:
  1. <?php
  2. function c_substr($string, $from, $length = null){
  3.     preg_match_all('/[\x80-\xff]?./', $string, $match);
  4.     if(is_null($length)){
  5.         $result = implode('', array_slice($match[0], $from));
  6.     }else{
  7.         $result = implode('', array_slice($match[0], $from, $length));
  8.     }
  9.     return $result;
  10. }
  11. $str = "zhon华人min共和guo";
  12. $from = 3;
  13. $length = 7;
  14. echo(c_substr($str, $from, $length));
  15. // 输出: n华人min共
  16. //还有utf-8的
  17. /*
  18. Regarding windix's function to handle UTF-8 strings:
  19. one can use the "u" modifier on the regular expression so that the pattern string is treated as UTF-8
  20. (available from PHP 4.1.0 or greater on Unix and from PHP 4.2.3 on win32).
  21. This way the function works for other encodings too (like Greek for example).
  22. The modified function would read like this:
  23. */
  24. function utf8_substr($str,$start) {
  25. $null = "";
  26.    preg_match_all("/./u", $str, $ar);
  27.    if(func_num_args()>= 3) {
  28.        $end = func_get_arg(2);
  29.        return join($null, array_slice($ar[0],$start,$end));
  30.    } else {
  31.        return join($null, array_slice($ar[0],$start));
  32.    }
  33. }
  34. ?>

又一个小项目结束了, 商城还是原来的进度, 着急没用, 放天假再说, 充分享受一下自由职业的自由度~~
干点啥呢?
玩游戏? 没意思, 没兴趣 :-(
泡论坛? 唯一可以畅所欲言的帝国忙着满足广告客户的需求, 不拿我们这些变态佬当会事 ;-(
学3D? 嗯, 这个不错, 先看看书吧, 看书的感觉最好了 :-) 可天气太热, 那个... -_-|||
对了, 国华老兄从新西兰回来了, 昨天跟琳琳要了他家电话, 赶快打一个... Read more...

影片名称: 雷蒙·斯尼奇的不幸历险
影视类型: 喜剧片
主要演员: 吉姆·凯瑞 裘德·洛 梅丽尔·斯特里普 Read more...

影片名称: 月亮上的人(Man on the Moon)
影视类型: 喜剧片
主要演员: 吉姆·凯瑞 丹尼·迪维图 玛丽露·亨纳尔 Read more...

闷了两天的天气终于爆发了, 大暴雨啊, 几十秒钟的时间地面上就水流成河, 爽~~~
终于可以睡个好觉了~~

麻烦的客户到处都有,又是修改,哎~~~
真是没办法, 最初不想好现在又改来改去!! 以后做东西之前尽量定好方案不让随便改, 否则这样改起来太麻烦了, 如果开始就这样要求的话就简单多了 :-(
郁闷~~
改吧,没办法,好在比较简单希望以后别再有修改了~~
祈祷ing...

最近每天早起锻炼, 羽毛球和踢毽, 明显精神百倍, 干活也有状态, hoho~~

Next Page »