The method to determine if the array is not empty in php is: 1. Use the [empty($array_test)] function. If the array [$array_test] is empty, the function returns true; 2. Use [if($array_test) )] Judgment condition, if the array is empty, the if judgment condition returns false.
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: the following one List them out
empty($array_test) //If the array $array_test is empty, then this function returns true
if($array_test) //If the array is empty, then the conditional judgment 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
Additional note
If the array is not defined
It can also be used
isset($array_test)//Judge whether the array is defined
Recommended tutorial: "php tutorial"
The above is the detailed content of What is the method to determine if an array is not empty in php. For more information, please follow other related articles on the PHP Chinese website!