Array_count_values () of the php array function sequence to count the number of occurrences of all values in the array function _ PHP Tutorial

Source: Internet
Author: User
The array_count_values () function of the php array function sequence counts the number of occurrences of all values in the array. Array_count_values () defines and uses the array_count_values () function to count the number of occurrences of all values in the array. This function returns an array. The key name of the element is the value of the original array. Array_count_values () definition and usage
The array_count_values () function is used to count the number of occurrences of all values in the array.

This function returns an array. The key name of the element is the value of the original array, and the key value is the number of times this value appears in the original array.

Syntax
Array_count_values (array) parameter description
Array is required. Specifies the input array.

Example

The code is as follows:


$ A = array ("Cat", "Dog", "Horse", "Dog ");
Print_r (array_count_values ($ ));
?>


Output:

Array ([Cat] => 1 [Dog] => 2 [Horse] => 1)

The http://www.bkjia.com/PHPjc/324495.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/324495.htmlTechArticlearray_count_values () definition and usage array_count_values () function is used to count the number of occurrences of all values in the array. This function returns an array. The key name of the element is the value of the original array...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.