PHP substr


substr cuts a string with specified offset and length.

<?PHP
	$str="The best time is no time at that time";
    echo substr($str,0,3);  //The
	echo substr($str,4,4);  //best
?>

If no length is specified, the function returns the substring from the offset till the end of string.
<?PHP
	$str="The best time is no time at that time";
    echo substr($str,3);  //best time is no time at that time
?>

substr() also supports negative numbers.
<?PHP
	$str="The best time is no time at that time";
    echo substr($str,-3);  //ime
    echo substr($str,4,-3);  //best time is no time at that t
?>