$str = \'HelloWorld\'; $sub = substr($str, 3, 5); echo $sub; // prints \"loWor\"
I know that substr() takes the first parameter, 2nd parameter is start
function my_substr_function($str, $start, $end) { return substr($str, $start, $end - $start); }
If you need to have it multibyte safe (i.e. for chinese characters, ...) use the mb_substr function:
function my_substr_function($str, $start, $end) { return mb_substr($str, $start, $end - $start); }