Bobafart
01-24-2008, 12:43 PM
Hiya,
I did a array_count_values() on my array and have the following sample print_r() result:
Array ( [fraud] => 2 [] => 2 [generale] => 2 [societe] => 2 [$7] => 1 [uncovered] => 1 [bank] => 1 [thursday] => 1 [uncovers] => 1 [massive] => 1 [french] => 1 [0] => 1 [billion] => 1 [orchestrated] => 1 [series] => 1 [bogus] => 1 [transactions] => 1 [trader] => 1 [futures] => 1 [one] => 1 [history] => 1 [biggest] => 1 [single] => 1 )
I want to only keep the elements in my array that appear more than 1 time (ie. delete all of the elements that appear only once). There needs to be a conditional however, that if there are only elements that appear once that it save the first 5 elements.
So if my array was:
Array ( [billion] => 1 [orchestrated] => 1 [series] => 1 [bogus] => 1 [transactions] => 1 [trader] => 1 [futures] => 1 [one] => 1 [history] => 1 [biggest] => 1 [single] => 1 )
it would save "billion, orchestrated, series, bogus and transactions"
how can I do this with PHP?
I did a array_count_values() on my array and have the following sample print_r() result:
Array ( [fraud] => 2 [] => 2 [generale] => 2 [societe] => 2 [$7] => 1 [uncovered] => 1 [bank] => 1 [thursday] => 1 [uncovers] => 1 [massive] => 1 [french] => 1 [0] => 1 [billion] => 1 [orchestrated] => 1 [series] => 1 [bogus] => 1 [transactions] => 1 [trader] => 1 [futures] => 1 [one] => 1 [history] => 1 [biggest] => 1 [single] => 1 )
I want to only keep the elements in my array that appear more than 1 time (ie. delete all of the elements that appear only once). There needs to be a conditional however, that if there are only elements that appear once that it save the first 5 elements.
So if my array was:
Array ( [billion] => 1 [orchestrated] => 1 [series] => 1 [bogus] => 1 [transactions] => 1 [trader] => 1 [futures] => 1 [one] => 1 [history] => 1 [biggest] => 1 [single] => 1 )
it would save "billion, orchestrated, series, bogus and transactions"
how can I do this with PHP?