PHP: Get nth character from end of string
Just do this
$rest = substr("abcdef", -3, 1); // returns 'd'
Like this:
function get_nth($string, $index) {
return substr($string, strlen($string) - $index - 1, 1);
}
Just do this
$rest = substr("abcdef", -3, 1); // returns 'd'
Like this:
function get_nth($string, $index) {
return substr($string, strlen($string) - $index - 1, 1);
}