$str = \'HelloWorld\'; $sub = substr($str, 3, 5); echo $sub; // prints \"loWor\"
I know that substr() takes the first parameter, 2nd parameter is start
Just subtract the start index from the end index and you have the length the function wants.
$start_index = 3; $end_index = 5; $sub = substr($str, $start_index, $end_index - $start_index);