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 Remove index.php from URL in Laravel
In this article, i will share with you h...How to compare two array values in PHP
Use the PHP array_diff() funct...How to detect enter key press on keyboard using jQuery
Use the key code 13 for Enter key The...Laravel 8 Google Recaptcha Tutorial Example
Google Recaptcha is Captcha service by G...JQuery click event not Working Issue Solved
JQuery is simple Javascript which makes...