Re: [PHP] Divide into words

2002-12-17 Thread Sean Burlington
how about ... Nope. The question was the position of the words, not how many times they appear. oops :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Divide into words

2002-12-16 Thread John W. Holmes
> > For example i have some words: > > > > Today is very beautiful day and sun is shining > > > > What i want to get from this is array > > > > words > > [Today] => 0 > > [Is] => 6,30 > > [Very] => 8 > > [beautiful] => 12 > > .. > > > > Can somebody please help me with this. Those nubers a

Re: [PHP] Divide into words

2002-12-16 Thread Sean Burlington
Uros Gruber wrote: Hi! For example i have some words: Today is very beautiful day and sun is shining What i want to get from this is array words [Today] => 0 [Is] => 6,30 [Very] => 8 [beautiful] => 12 .. Can somebody please help me with this. Those nubers are position of special word

Re: Re[2]: [PHP] Divide into words

2002-12-16 Thread 1LT John W. Holmes
> Yes, but my example was geared towards trying to work through a more > generic scenario. I'll bet if you try using perl regex with callback > it'll be even faster. I'll take that bet and say using preg_*_callback will be slower. :) I'll try and time each of them tonite and post what I find. Som

Re: Re[2]: [PHP] Divide into words

2002-12-16 Thread Marco Tabini
Yes, but my example was geared towards trying to work through a more generic scenario. I'll bet if you try using perl regex with callback it'll be even faster. Marco -- php|architect - The magazine for PHP Professionals The monthly worldwide magazine dedicated to PHP programmers Co

Re[2]: [PHP] Divide into words

2002-12-16 Thread Uros Gruber
Hi! I have dome almost the same $input = 'Today is a very beautiful day and the sun is shining'; $output = array(); $words = explode(' ',$input); $cur_pos = 0; foreach($words as $word) { if(!empty($output[$word])){ $output[$word] .= ','.$cur_pos; } else { $output[$word]

RE: [PHP] Divide into words

2002-12-16 Thread John W. Holmes
onals. Get your copy today. http://www.phparch.com/ > -Original Message- > From: Marco Tabini [mailto:[EMAIL PROTECTED]] > Sent: Monday, December 16, 2002 12:37 PM > To: [EMAIL PROTECTED] > Cc: 'Uros Gruber'; PHP-General > Subject: RE: [PHP] Divide into words >

RE: [PHP] Divide into words

2002-12-16 Thread Marco Tabini
John, I'm not sure this will work if there is more than one space between words. Also, my previous example won't work if there are duplicate words (although it's easy to make an array out of each word and solve the problem), nor if the words are delimited by any character other than spaces, in wh

RE: [PHP] Divide into words

2002-12-16 Thread John W. Holmes
> For example i have some words: > > Today is very beautiful day and sun is shining > > What i want to get from this is array > > words > [Today] => 0 > [Is] => 6,30 > [Very] => 8 > [beautiful] => 12 > .. > > Can somebody please help me with this. Those nubers are > position of special

Re: [PHP] Divide into words

2002-12-16 Thread Marco Tabini
You could use strpos--there are easier ways if you don't need the offsets. Example: This is from memory, but it looks like it should work even for weird strings like the one above. Cheers, Marco -- php|architect - The magazine for PHP Professionals The monthly worldwide magazin

[PHP] Divide into words

2002-12-16 Thread Uros Gruber
Hi! For example i have some words: Today is very beautiful day and sun is shining What i want to get from this is array words [Today] => 0 [Is] => 6,30 [Very] => 8 [beautiful] => 12 .. Can somebody please help me with this. Those nubers are position of special word in above sentence.