source: branches/dev/html/test/uehara/test.php @ 394

Revision 394, 516 bytes checked in by uehara, 16 years ago (diff)
RevLine 
[8]1<?php
[391]2function sfCutStringByte($str, $len) {
3    if(strlen($str) > $len) {
4        $ret = $str;
5        for($i = 1; $len >= $i; $i++) {
6            $ret = mb_substr($ret, 0, $len - $i);
7            if(strlen($ret) <= $len) break;
8        }
9    } else {
10        $ret = $str;
11    }
[8]12
[391]13    return $ret;
14}
15
[394]16$str = "¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢";
[391]17
18echo sfCutStringByte($str, 100);
[8]19?>
Note: See TracBrowser for help on using the repository browser.