How to determine if an array has any elements or not?

后端 未结 8 2012
青春惊慌失措
青春惊慌失措 2020-12-06 09:31

How do I find if an array has one or more elements?

I need to execute a block of code where the size of the array is greater than zero.

if ($result &         


        
8条回答
  •  执笔经年
    2020-12-06 10:07

    @Sajid Mehmood in PHP we have count() to count the length of an array, when count() returns 0 that means that array is empty

    Let’s take an example for your understanding:

提交回复
热议问题