count all elements or values in an array in PHP

count all elements or values in an array in PHP

In this post we will give you information about count all elements or values in an array in PHP. Hear we will give you detail about count all elements or values in an array in PHPAnd how to use it also give you demo for it if it is necessary.

Use the PHP count() or sizeof() function


You can simply use the PHP count() or sizeof() function to get the number of elements or values in an array. The count() and sizeof() function returns 0 for a variable that has been initialized with an empty array, but it may also return 0 for a variable that isn’t set.


You can additionally use the isset() function to check whether a variable is set or not.



<?php
$days = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
 
// Printing array size
echo count($days);
echo "<br>";
echo sizeof($days);
?>


 

Hope this and post will helped you for implement count all elements or values in an array in PHP. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

7  +  1  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US