note 26544 deleted from function.substr by aidan
| From: | aidan@php.net | Date: | Sat, 03 Jul 2004 07:52:56 +0000 |
| Subject: | note 26544 deleted from function.substr by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72380@lists.php.net to get a copy of this message | ||
Note Submitter: kenlo@msi.com.tw
----
if your php version below 4.06, you can try my function for multi-byte string:
function chSubstr($string, $start=0, $length=0) {
if ($start > 0) {
$bound_test = substr($string, 0, $start);
if (preg_match("/[x7F-xFF]$/", $bound_test)) {
$start++;
}
}
if ($length > 0) {
$out = substr($string, $start, $length);
if (preg_match("/[x7F-xFF]$/", $out)) {
$out = substr($string, $start, ++$length);
}
return $out;
} else {
return substr($string, $start);
}
}
after php 4.06, try mb_substr() ;)