PHP Formatter

A Unique Blog about PHP

Array Count Values

The array_count_values() function returns an array which contains the keys of the original array’s value and the value is the number of occurences. A sample of it’s use is shown below:

$a=array("Mouse","Cat","Dog","Cat"); print_r(array_count_values($a)); ?>

Which would give us an output of : Array ( [Mouse]=> 1 [Cat]=> 2 [Dog]=> 1 )

The next functions are used to compare the contents of one array against one or more arrays either returning the key, keys and contents or solely the contents of the specified fields that result from their comparisons. They are array_diff(), array_diff_assoc(), array_diff_key(), array_diff_uassoc() and array_diff_ukey(). all of these are used to determine the difference between a set of arrays returning either the keys or contents to give the results of the said array comparison/s.