
- PHP Tutorial
- PHP - Home
- PHP - Introduction
- PHP - Environment Setup
- PHP - Syntax Overview
- PHP - Variable Types
- PHP - Constants
- PHP - Operator Types
- PHP - Decision Making
- PHP - Loop Types
- PHP - Arrays
- PHP - Strings
- PHP - Web Concepts
- PHP - GET & POST
- PHP - File Inclusion
- PHP - Files & I/O
- PHP - Functions
- PHP - Cookies
- PHP - Sessions
- PHP - Sending Emails
- PHP - File Uploading
- PHP - Coding Standard
- Advanced PHP
- PHP - Predefined Variables
- PHP - Regular Expression
- PHP - Error Handling
- PHP - Bugs Debugging
- PHP - Date & Time
- PHP & MySQL
- PHP & AJAX
- PHP & XML
- PHP - Object Oriented
- PHP - For C Developers
- PHP - For PERL Developers
- PHP Form Examples
- PHP - Form Introduction
- PHP - Validation Example
- PHP - Complete Form
- PHP login Examples
- PHP - Login Example
- PHP - Facebook Login
- PHP - Paypal Integration
- PHP - MySQL Login
- PHP AJAX Examples
- PHP - AJAX Search
- PHP - AJAX XML Parser
- PHP - AJAX Auto Complete Search
- PHP - AJAX RSS Feed Example
- PHP XML Example
- PHP - XML Introduction
- PHP - Simple XML
- PHP - Simple XML GET
- PHP - SAX Parser Example
- PHP - DOM Parser Example
- PHP Frame Works
- PHP - Frame Works
- PHP - Core PHP vs Frame Works
- PHP Design Patterns
- PHP - Design Patterns
- PHP Function Reference
- PHP - Built-In Functions
- PHP Useful Resources
- PHP - Questions & Answers
- PHP - Useful Resources
- PHP - Discussion
PHP array_count_values() Function
Definition and Usage
The array_count_values() function returns an associative array of values using the values of the input array as keys and their frequency in input array as values.
Syntax
array array_count_values ( array $input );
Parameters
Sr.No | Parameter & Description |
---|---|
1 |
input (mandatory) The input array of values to count |
Return Values
It returns an associative array of values from input as keys and their count as value.
PHP Version
This function was first introduced in PHP Version 4.0.0.
Errors/Exceptions
This will throw E_WARNING for every element which is not string or integer.
Example
Try out following example −
<?php $input = array("orange", "mango", "banana", "orange", "banana" ); print_r(array_count_values($input)); ?>
This will produce the following result −
Array ( [orange] => 2 [mango] => 1 [banana] => 2 )
Example
Try out following example with all integer values −
<?php $input = array(10, 15, 30, 15, 10); print_r(array_count_values($input)); ?>
This will produce the following result −
Array ( [10] => 2 [15] => 2 [30] => 1 )
php_function_reference.htm
Advertisements