in array length in php, You can easy use the main Two types of the ways first is a PHP count() as well as sizeof() method to get the number of elements as well as data values in an array. The count() and sizeof() method results data returns 0 for a variable that has been initialized with an empty array, so it may also results return 0 for a php variable that is not any set.
array length in php
- using count() function
- using sizeof() function
PHP count() function
<!DOCTYPE html> <html lang="en"> <head> <title>Example of Counting an Array Values in PHP</title> </head> <body> <h2>array length in php</h2> <?php $movies = array("tamilrokers", "jiorokers", "bolly4u", "mymaths", "litanswers", "khatrimaza", "pakainfo"); // display array size echo 'Your Total number of movies in the $movies array is - ' . count($movies); echo "<br>"; echo 'Your Total number of movies in the $movies array is - ' . sizeof($movies); ?> </body> </html>
PHP Array Lengths Size Count Tutorial With Example
PHP sizeof() function
<!DOCTYPE html> <html> <body> <?php $movies=array ( "tamilrokers"=>array ( "TAMIL", "HINDI" ), "JIO"=>array ( "PAKA", "INFO" ), "BOLYY4U"=>array ( "okhatrimaja" ) ); echo "Normal count: " . sizeof($movies)."<br>"; echo "Recursive count: " . sizeof($movies,1); ?> </body> </html>
I hope you get an idea about array lengths in php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.
Here are some more FAQ related to this Article: