count arrays - PHP -


i have array

$array = array(array('b','d'),                  array('c','a'),                 array('b','d'),                 array('a','d'),                 array('c'),                 array('c'),                 array('a','d','e'),                 array('d','b')                  );  $result = array(array('c'),array('a','d'), array('b','d'), array('a,','d','e')) ; 

here's code:

    foreach ($array $part) {         $key = implode(', ', $part);         if( ! array_key_exists ($key, $result)) {             $result[$key] = 0;         }         $result[$key] = $result[$key] + 1;     }     foreach ($result $key => $value) {         echo "$value of {$key}<br/>";        } 

and got this:
2 of b, d
1 of c, a
1 of a, d
2 of c
1 of a, d, e
1 of d, b

i want result this:

3 of c       2 of a, d 2 of b, d   1 of a, d, e   

did try array_count_values() ?

bye.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -