Php statistics on the number of array elements, php statistics on the number of Arrays
Count (): counts the number of elements in the array;
Sizeof (): it has the same purpose as count (). Both functions can return the number of array elements. we can get the number of elements in a regular scalar variable. If the array passed to this function is an empty array or an unspecified variable, the number of returned array elements is 0;
Array_count_value (): counts the number of times each specific value has exceeded in the array $ array;
For example:
$ Array = array (,); $ ac = array_count_value ($ array );
An array named $ ac will be created, including:
Keyword value: 4 1 5 1 1 3 2 3 1
The idea of sending a netizen is also very good.
$ Arr = array ('2014, 1011,100, 1009, 1011,100, ', '2014,'); $ result = array (); foreach ($ arr as $ str) {$ str_arr = explode (',', $ str); foreach ($ str_arr as $ v) {$ result [$ v] = isset ($ result [$ v])? $ Result [$ v]: 0; $ result [$ v] = $ result [$ v] + 1 ;}} print_r ($ result );
The above is all the content of this article. I hope you will like it.