Here's a string: "all cows eat grass"
How do we make this say "grass eat cows all"?
If I understand, this is not something strrev() does. So my thought was to put the string in a variable, put in into an array word by word by stripping spaces, then loop through the array backward (How do you loop through an array backward (x--) without going to -1, -2, etc?), then put the elements into a string form in a variable, then print it. That seem right?
How to print word order backwards?
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
explode() will be useful here too
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA