With substr() you can omit the third parameter to get the whole rest of the string:
substr('abcdefg', 2) // returns "cdefg"
You can’t do the same with mb_substr():
mb_substr('abcdefg', 2, null, 'UTF-8'); // returns empty string
I only found weird and ugly solutions.
-
Setting a very high number as length:
$a = mb_substr('abcdefg', 2, 9999999999, 'UTF-8'); -
Calculating the number:
$a = mb_substr('abcdefg', 2, mb_strlen('abcdefg', 'UTF-8') - 2, 'UTF-8'); -
Omitting the charset parameter by using
mb_internal_encoding():$temp = mb_internal_encoding(); // prevent action at a distance
mb_internal_encoding('UTF-8');
$a = mb_substr('abcdefg', 2);
mb_internal_encoding($temp);
Isn’t there a real solution?
Change log shows this as a bug fix in Version 5.4.8 (18-October-2012).
http://us.php.net/ChangeLog-5.php
Here is a link to the pull request thread also: https://github.com/php/php-src/pull/133