note 26544 added to function.substr

From: Date: Mon, 04 Nov 2002 09:39:34 +0000
Subject: note 26544 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-38943@lists.php.net to get a copy of this message
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() ;) -- http://www.php.net/manual/en/function.substr.php http://master.php.net/manage/user-notes.php?action=edit+26544 http://master.php.net/manage/user-notes.php?action=delete+26544 http://master.php.net/manage/user-notes.php?action=reject+26544

« previous php.notes (#38943) next »