separating a sentence into words

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post September 10th, 2003, 1:52 am

Okay so let me get this straight. You want to reverse the words and not the text per line? because if it was the text you were wanting reversed on each line it would look something like:

!gninrom dooG

;1 = 2-3

and if you wanted just the words reversed (ie things seperated by spaces) it would look something like:

morning! Good

1; = 3-2

There is a big difference, so I just want to clarify this.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 10th, 2003, 1:52 am

  • baby_eye_26
  • Born
  • Born
  • No Avatar
  • Joined: Sep 10, 2003
  • Posts: 2
  • Status: Offline

Post September 10th, 2003, 3:30 am

sorry...i want to reverse the line...that means if input is Good morning!, the output should be morning! Good...
  • £het®
  • Newbie
  • Newbie
  • User avatar
  • Joined: Sep 08, 2003
  • Posts: 5
  • Status: Offline

Post September 10th, 2003, 7:37 am

oh ok... If I were to do this, i'll make it this way... in php hehehehe :D

1. pass the lines/sentences as array either by using explode, etc.
2. pass each word as array.
3. loop from max to 0 of each array starting from the word array

for the simplest start:
Code: [ Select ]
$str = "This is the whole sentence";

$word = split(' ',$str);

for($i=count($word);$i>=0;$i--){
    echo $word[$i]." ";
}
  1. $str = "This is the whole sentence";
  2. $word = split(' ',$str);
  3. for($i=count($word);$i>=0;$i--){
  4.     echo $word[$i]." ";
  5. }

Post Information

  • Total Posts in this topic: 18 posts
  • Users browsing this forum: No registered users and 153 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.