Today, We want to share with you how to check array is empty in php.In this post we will show you empty php, hear for php array length we will give you demo and example for implement.In this post, we will learn about checks array empty with an example.
php check if string is empty or whitespace
Using empty() Function:
<?php $non_empty_array = array('URL' => 'https://www.pakainfo.com/'); $empty_array = array(); if(!empty($non_empty_array)) echo "Given Array is not empty <br>"; if(empty($empty_array)) echo "Given Array is empty"; ?>
Using count Function:
<?php $empty_array = array(); if(count($empty_array) == 0) echo "Array is empty"; else echo "Array is non- empty"; ?>
Using sizeof() function:
<?php $empty_array = array(); if( sizeof($empty_array) == 0 ) echo "Empty Array"; else echo "Non-Empty Array"; ?>
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.