Home  >  Article  >  Backend Development  >  How to determine if an array is not empty in php

How to determine if an array is not empty in php

hzc
hzcOriginal
2020-06-08 09:32:472564browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn