PHP substr() function will substract or returns the portion of string specified by the start and length parameters.
substr($string , int $start [, int $length ] )
-
<?php
-
$sub = substr("abcdef", -2); // returns "ef", -2 represent starting from 2 character back
-
$sub = substr("abcdef", -3, 1); // returns "d", -3 represent starting from 3 character back and 1 the length of the substraction
-
echo substr('abcdef', 0, 3); // returns "abc", starting from 0 to 3
-
-
// you can substract only one character
-
$string = 'abcdef';
-
echo $string[3]; // returns "d", the third character
-
?>