Re: Reversing a string?
| From: | Mendle | Date: | Fri, 14 May 2004 10:06:14 +0000 |
| Subject: | Re: Reversing a string? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-186222@lists.php.net to get a copy of this message | ||
<?php
$str = "Hello World";
echo strrev($str);
?>
http://ie2.php.net/strrev
Regards
"Kristian Rasmussen" <kristian@amazing.as> wrote in message
news:20040513212741.83074.qmail@pb1.pair.com...
> Hi all,
>
> I need a script for reversing a string ("hello world" becomes "dlrow
> olleh"). I have tried the following:
>
> ---
> $length = strlen($i);
> $g = "";
>
> while ($length > 0)
> {
> $g = $i[$length] . $g;
> $length--;
> }
> echo $g;
> ---
>
> With, obviously, no success. Is this the way or could array_reverse()
> somehow be used?
>
> Kristian