How to detect duplicate values in PHP array? -


I am working with a one dimensional array in PHP. I would like to know the presence of duplicate values, then the number of duplicate values ​​is counted and the result is drawn. For example, the following arrays were given:

  $ array = array ('apple', 'orange', 'pear', 'banana', 'apple', 'pears',' kiwi ',' Kiwi ',' Kiwi ');  

I would like to print:

  apples (2) orange pears (2) banana kiwi (3)  

How to approach this problem but any advice?

Thank you.

  $ array = Array ('apple', 'orange', 'pear', 'banana', 'apple', 'pear', 'kiwi' kiwi, 'kiwi'); Print_r (array_count_values ​​($ array));  

output

  array ([apple] = & gt; 2 [orange] => 1 [pear] => 2 etc. ..)  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -