Re: [PHP] twodimensional array / word-frequencylist

2003-06-26 Thread David Otton
On Thu, 26 Jun 2003 13:25:39 +0200, you wrote: ># i would like a similar function that removes interpuntuation like "." etc. ># all i want remaining in the array are the separate words, all in lower >case How do you define a word? Is a hyphen part of a word? Do you want to strip out numbers? Make

RE: [PHP] twodimensional array / word-frequencylist

2003-06-26 Thread Naintara Jain
Very simple, there's a function designed just for this. check out the manual for array_count_values() array_count_values() returns an array using the values of the input array as keys and their frequency in input as values. EXAMPLE: $array = array (1, "hello", 1, "world", "hello"); print_r(array_

Re: [PHP] twodimensional array / word-frequencylist

2003-06-26 Thread David Nicholson
Hello, This is a reply to an e-mail that you wrote on Thu, 26 Jun 2003 at 12:36, lines prefixed by '>' were originally written by you. > foreach($words as $thisword){ > if(in_array($thisword, $array)){ > $array[$thisword]++; > } else { > $array[$thisword]=1; > } Just

Re: [PHP] twodimensional array / word-frequencylist

2003-06-26 Thread David Nicholson
Hello, This is a reply to an e-mail that you wrote on Thu, 26 Jun 2003 at 12:26, lines prefixed by '>' were originally written by you. > # i would like a similar function that removes interpuntuation like > "." etc. > # all i want remaining in the array are the separate words, all in > lower > ca

Re: [PHP] twodimensional array / word-frequencylist

2003-06-26 Thread Chris Hayes
if (!isset($words[$word] $words[$word]=0; else $words[$word]++; } change the 0 to 1 of course. Anyway the function Jason suggested is probably faster. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] twodimensional array / word-frequencylist

2003-06-26 Thread Chris Hayes
There may be faster ways, for instance using the regular expression function that returns an array of hits, and make the regexp look for 'words' in it with the \b option. But i will stick to your example code. My suggestions are not tested. while($myrow = mysql_fetch_row($result)) # as long as t

Re: [PHP] twodimensional array / word-frequencylist

2003-06-26 Thread Jason Wong
On Thursday 26 June 2003 19:25, Dore van Hoorn wrote: [snip] > # i would like a function that pushes this word into a second array. > # before pushing, it has to check whether or not the same word is already > in the array. > # if it is: do not push word into array, but add "1" to the number of >