Code used to determine whether the PHP array is empty. The preferred method for PHP to determine whether an array is empty: count ($ arr), size ($ arr); copy the code as follows: $ arrarray (); echocount ($ arr ); echosize ($ arr); the output 1 Copy code is as follows: $ arr PHP preferred method for determining the array is null: count ($ arr), size ($ arr );
The code is as follows:
$ Arr = array ("");
Echo count ($ arr );
Echo size ($ arr );
// Output 1
The code is as follows:
$ Arr = array ();
Echo count ($ arr );
Echo size ($ arr );
// Output 0
PHP method 2 for null array determination: empty ($ arr );
The code is as follows:
$ Arr = array ("");
$ Result = empty ($ arr );
// $ Result = false
$ Arr = array ();
$ Result = empty ($ arr );
// $ Result = true
These two methods can be used to determine whether a simple array or multi-dimensional array is null. In general, empty () is used to determine whether the array is not empty. This makes the code easier to understand.
Values ($ arr), size ($ arr); the code is as follows: $ arr = array (""); echo count ($ arr); echo size ($ arr ); // output 1 code: $ arr =...