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

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -