how to check array is empty in php?

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 hope you get an idea about check array is empty javascript with PHP.
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.

Read Also:  Laravel Custom Dropdown Server Side Filter in Datatables

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  PHP prepend leading zero prefixes after number
  2. Read Also:  Laravel Auto redirect if not logged in
  3. Read Also:  vuejs Tutorials - vuejs component
  4. Read Also:  PHP Array Length size count Function with Example
  5. Read Also:  jQuery Get the Text Value of Selected Option
  6. Read Also:  Get Computer Hardware Information using C#
  7. Read Also:  How to check array is empty or not in php?
  8. Read Also:  Multi Dimensional Array Sorting in Php
  9. Read Also:  PHP Laravel Check if Array is empty
  10. Read Also:  How to Convert String to array in php Examples
CLOSEX