Home >Backend Development >PHP Problem >How to determine how many values an array has in php
In PHP, you can use the count() function to determine how many values an array has; this function can count the number of elements in the array and return the number of elements. The syntax format is "count(array) ", its parameter array represents the array to be counted. When using it, you only need to pass the array into array.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, you can use count () function to determine how many values an array has.
$arr = Array('0','1','2','3','4'); echo count($arr); // 输出 5
Output:
5
Description:
count(): Count the number of elements in the array Perform statistics and return the number of elements in the array.
Syntax
count(array,mode);
Parameters | Description |
---|---|
array | Required. Specifies the array to count. |
mode | Optional. Specifies the mode of the function. Possible values:
|
Recommended study: "PHP Video Tutorial"
The above is the detailed content of How to determine how many values an array has in php. For more information, please follow other related articles on the PHP Chinese website!