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] Quote Link to comment 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. Quote Link to comment 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! Quote Link to comment 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... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.