Skip to content

Instantly share code, notes, and snippets.

@juanramon
Created April 26, 2011 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanramon/942527 to your computer and use it in GitHub Desktop.
Save juanramon/942527 to your computer and use it in GitHub Desktop.
Implementation of mb_substr function
<?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