Home > Article > Backend Development > How to determine if an array is not empty in php
The way to determine whether the array is empty in php is:
The array is empty. It means that the array does not contain any elements.
There are many ways to judge that the array is empty: List them one by one below
empty($array_test)
//If the array $array_test is empty, then So this function returns true
if($array_test)
//If the array is empty, then the condition of if is false
count($array_test)
//Calculate the number of array elements. If it is 0, it is empty
sizeof($array_test)
//The alias usage of count() is the same as the return
/ /In fact, there are some ways to judge whether the array is empty. The commonly used ones are these
Add
If the array is not defined
You can also use
isset($array_test)
//Judge whether the array is defined
Recommended tutorial: "php tutorial"
The above is the detailed content of How to determine if an array is not empty in php. For more information, please follow other related articles on the PHP Chinese website!