There are a number of values ​​to check for empty array

<?php $arr1 = array(" "); var_dump(empty($arr1)); $arr2 = array(0); var_dump(empty($arr2)); $arr3 = array(null); var_dump(empty($arr3)); $arr4 = array(false); var_dump(empty($arr4)); ?> 

In the version of php 5.3.3, it displays everything false . But in versions of php 5.4 and higher it will be true ?

  • Here you can check for yourself on 5.3-7.0 phptester.net - cronfy

2 answers 2

No, the behavior of the empty language construct has not changed for a long time, probably even in php4 the result was the same. The result in PHP5.x and the current 7.0 and 7.1 will still be 4 false .

About future versions I will not say. Maybe someday, and change the behavior, but such plans have not yet been heard.

    I have version 5.4 such result bool(false) bool(false) bool(false) bool(false)