Print a string backwards php -
Print a string backwards php -
i want print string backwards/reverse. tried
$string = 'hello'; ($i = 0; $i < strlen($string);$i++) { $string1[] = $string[$i]; } $array = array_reverse($string1); foreach ($array $a) { echo $a; } and works, isn't easier there?
use strrev()
echo strrev($string); just kicks, here's alternative way using arrays in illustration using implode(), array_reverse(), , str_split():
echo implode('', array_reverse(str_split($string))); php string
Comments
Post a Comment