Today, We want to share with you php array length.In this post we will show you php array length for loop, hear for Php get size of array in bytes we will give you demo and example for implement.In this post, we will learn about PHP Array Length Size Count Tutorial with an example.
php array length
Example 1 : PHP count() Function
<!DOCTYPE html> <html> <body> <?php $members=array("Rekha","Dipti","Krishna"); echo count($members); ?> </body> </html>
Example 2 : Get the length of an array in PHP
//An array of names. $names = array( 'Jay', 'Janbvi', 'Mayuri', 'Longi', 'Tridsha' ); //Get the number of members in the array by //using PHP's inbuilt count() function. $numElements = count($names); //Print it out. echo $numElements;
Example 3 : Use the PHP count() or sizeof() function
<!DOCTYPE html> <html lang="en"> <head> <title>Example of Counting an Array Values in PHP</title> </head> <body> <?php $members = array("Suraj", "Manoj", "Trupti", "Wedu", "Raghav", "Falguni", "Shital"); // displaying array size echo 'Total number of members in the $members array is - ' . count($members); echo "<br>"; echo 'Total number of members in the $members array is - ' . sizeof($members); ?> </body> </html>
I hope you get an idea about php array length.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.