How to print word order backwards?
Posted: Mon May 15, 2006 5:53 pm
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 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?