@RJosh
$tok = explode($string,$c);
$c should come before $string and your missing a few semicolons the code doesn't work for negative ranges either