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

Revision 394, 516 bytes checked in by uehara, 16 years ago (diff)
Line 
1<?php
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    }
12
13    return $ret;
14}
15
16$str = "¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢¤¢";
17
18echo sfCutStringByte($str, 100);
19?>
Note: See TracBrowser for help on using the repository browser.