Reversing a string?
| From: | Kristian Rasmussen | Date: | Thu, 13 May 2004 21:22:04 +0000 |
| Subject: | Reversing a string? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-186157@lists.php.net to get a copy of this message | ||
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