How to determine how many values ​​an array has in php

青灯夜游
Release: 2023-03-09 18:50:01
Original
3440 people have browsed it

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.

How to determine how many values ​​an array has in php

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
Copy after login

Output:

5
Copy after login

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);
Copy after login
Parameters Description
array Required. Specifies the array to count.
mode Optional. Specifies the mode of the function. Possible values:
  • 0 - Default. Not counting all elements in a multidimensional array.
  • 1 - Recursively count the number of elements in an array (count all elements in a multidimensional array).

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!