Created
April 26, 2011 15:53
-
-
Save juanramon/942527 to your computer and use it in GitHub Desktop.
Implementation of mb_substr function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Check if mb_substr function is loaded. In case it is not loaded, we implement it. | |
*/ | |
if ( !function_exists('mb_substr') ) { | |
function mb_substr( $str, $start, $length = null, $encoding = null ) { | |
preg_match_all( '/./us', $str, $match ); | |
$chars = is_null( $length ) ? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length ); | |
return implode('', $chars ); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment