Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-11-2007, 12:49 AM   PM User | #1
inVINCEable
New Coder

 
Join Date: Apr 2007
Posts: 85
Thanks: 1
Thanked 0 Times in 0 Posts
inVINCEable is an unknown quantity at this point
Grabbing a random list of items, one per line?

Hey guys,

Sorry I am pretty stuck, what I want to do though is search these lines of data, line by line, and grab a random word from each line, until a reach a limit. So far I have this,


foreach ($test as $tag){

$newtag = $tag['Story'];



$tags = implode(',', $newtag);

}

^What this gives me is a result like this:



computer, believe, see, hate

computer, newegg

person, walking





Now how can I loop through these lines to grab a random word from each one, until I reach a limit, say 10. What I had in mind was a while loop, something like this,

foreach ($test as $tag){

$newtag = $tag['Story'];



$tags = implode(',', $newtag);
//$data = pr($tags);
echo $tags;
echo "<br />";

}


Any suggestions? Thanks.
__________________
I am on my way. :)
inVINCEable is offline   Reply With Quote
Old 07-11-2007, 06:57 AM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Try using array_rand().
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:29 AM.


Advertisement
Log in to turn off these ads.