Home >Backend Development >PHP Problem >How to find the sum of array numbers in php
How to find the sum of the number of arrays in php: 1. Create a new php sample file; 2. Define a $Cities array; 3. Use the "count()" function to count the number of elements in the $Cities array And output; 4. Run the web page and check the number of output array elements.
The operating environment of this tutorial: windows10 system, PHP8.1 version, DELL G3 computer
How to find the number of arrays in php of and?
Create a new 126.php, as shown in the figure:
Enter the structure of the php web page (), As shown in the figure:
Declares the file type and encoding for PHP to interact with the browser, as shown in the figure:
Define a $Cities array, as shown in the figure:
Use the count() function to count the number of elements in the $Cities array and output it, as shown in the figure:
Run the web page and check the number of output array elements, as shown in the figure:
Recommended study: "PHP video tutorial》
The above is the detailed content of How to find the sum of array numbers in php. For more information, please follow other related articles on the PHP Chinese website!