寧毅網絡工作室

          寧毅網絡工作室提供專業的網站設計維護制作服務

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            18 隨筆 :: 93 文章 :: 28 評論 :: 0 Trackbacks
          1. ?
          2. <?php
          3. /***************************************************/
          4. /*? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?*/
          5. /*??Author:? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ???*/
          6. /*??HomePage: www..com? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?*/
          7. /*??Email: phforum@163.com? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?*/
          8. /*??QQ:1984412? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?*/
          9. /*? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?*/
          10. /***************************************************/
          11. ?
          12. function get_substr($string,$start='0',$length='')
          13. {
          14. $start = (int)$start;
          15. $length = (int)$length;
          16. $i = 0;
          17. if (!$string)
          18. {
          19. ??return;
          20. }
          21. if ( $start>=0)
          22. {
          23. ??while($i<$start)
          24. ??{
          25. ? ?if(ord($string[$i])>127)
          26. ? ?{
          27. ? ? $i = $i+2;
          28. ? ?}
          29. ? ?else
          30. ? ?{
          31. ? ? $i++;
          32. ? ?}
          33. ??}
          34. ??$start = $i;
          35. ??if($length=='')
          36. ??{
          37. ? ?returnsubstr($string,$start);
          38. ??}
          39. ??elseif($length>0)
          40. ??{
          41. ? ?$end = $start+$length;
          42. ? ?while($i<$end)
          43. ? ?{
          44. ? ? if(ord($string[$i])>127)
          45. ? ? {
          46. ? ???$i = $i+2;
          47. ? ? }
          48. ? ? else
          49. ? ? {
          50. ? ???$i++;
          51. ? ? }
          52. ? ?}
          53. ? ?if($end != $i-1)
          54. ? ?{
          55. ? ? $end = $i;
          56. ? ?}
          57. ? ?else
          58. ? ?{
          59. ? ? $end--;
          60. ? ?}
          61. ? ?$length = $end-$start;
          62. ? ?returnsubstr($string,$start,$length);
          63. ??}
          64. ??elseif($length==0)
          65. ??{
          66. ? ?return;
          67. ??}
          68. ??else
          69. ??{
          70. ? ?$length = strlen($string)-abs($length)-$start;
          71. ? ?return get_substr($string,$start,$length);
          72. ??}
          73. }
          74. else
          75. {
          76. ??$start = strlen($string)-abs($start);
          77. ??return get_substr($string,$start,$length);
          78. }
          79. }
          80. ?
          81. ?>
          82. ?
          posted on 2007-01-15 17:35 寧毅網絡工作室 閱讀(173) 評論(0)  編輯  收藏 所屬分類: PHP技術備藏
          主站蜘蛛池模板: 漳浦县| 天门市| 新河县| 丹东市| 北安市| 广宁县| 新沂市| 夏津县| 营山县| 巴里| 志丹县| 台山市| 姚安县| 禹城市| 汽车| 涞源县| 佛教| 深水埗区| 荆州市| 舒兰市| 滨海县| 宁晋县| 合作市| 三台县| 霍邱县| 福海县| 壤塘县| 乌拉特后旗| 杂多县| 宿松县| 都江堰市| 泰和县| 西乡县| 东辽县| 灌阳县| 星座| 陵川县| 武宁县| 沂源县| 永丰县| 原阳县|