Concept
How can you count the elements in a PHP array?
ComputerScienceOne / Useful Functions
"There are dozens of useful functions PHP defines that can be used with arrays. We’ll only highlight a few of the more useful ones. First, the count() function can be used to compute how many elements are stored in the array.\n\n$arr = array(10, 20, 30);\n\n$n = count($arr); //n is 3"
Related Ideas
- How can you iterate over indexed and associative arrays in PHP?ComputerScienceOne · Iteration
- How does unset() remove elements from a PHP array?ComputerScienceOne · Removing Elements
- Can PHP array indices be non-contiguous?ComputerScienceOne · Strings as Indices
- Which PHP functions return an array’s keys and values?ComputerScienceOne · Useful Functions
- How can you add elements to an array?ComputerScienceOne · Adding Elements
- How are elements added to the next available integer index in a PHP array?ComputerScienceOne · Removing Elements
- How do you create and index arrays in PHP?ComputerScienceOne · Creating Arrays
- How can you iterate through an array using foreach?ComputerScienceOne · Adding Elements