pro_se Posted December 6, 2006 Share Posted December 6, 2006 I am writing a code that will read a user input and flip the text around. I have the code made so if you have a space it will reverse it but i want it if you input: 'car' it will say 'rac'... any help will be appreciated![code]<?phpif (isset ($_POST["flip"])) { $text = $_POST['text'];$brokenup = explode(" ", $text);echo $brokenup[1];echo $brokenup[0];}?>[/code] Link to comment https://forums.phpfreaks.com/topic/29676-make-string-read-backwards/ Share on other sites More sharing options...
joquius Posted December 6, 2006 Share Posted December 6, 2006 I won't go into the details, but get the length of the text, start reading it from the last character to the first with a loop while copying each character to a new string. Link to comment https://forums.phpfreaks.com/topic/29676-make-string-read-backwards/#findComment-136202 Share on other sites More sharing options...
trq Posted December 6, 2006 Share Posted December 6, 2006 [url=http://php.net/strrev]strrev[/url]. Duh! Link to comment https://forums.phpfreaks.com/topic/29676-make-string-read-backwards/#findComment-136214 Share on other sites More sharing options...
joquius Posted December 6, 2006 Share Posted December 6, 2006 Aha there's a function for that. God knows why... Link to comment https://forums.phpfreaks.com/topic/29676-make-string-read-backwards/#findComment-136216 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.