count()
or sizeof()
functionYou 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);
?>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
How To Build Your First React JS Application
React.js is one of the most popular Java...How to get last inserted id in Laravel 8
When you insert any record in database,...Laravel 8 - Encrypted and Decrypted Data using openssl_encrypt
In this article, I will share with you h...Django - How to Create Custom Login Page
Within this article we will look at how...How to Protect Image from Public View in Laravel 8
If you are running a image website, wher...