Php judges that the array is empty for two instances. The following provides the php code for determining whether the array is null. because the array is a composite data type, we cannot process it like other complex data types. let's look at the example below. Method 1: Use the php code below the cou to provide two arrays to judge as null. because the array is a composite data type, we cannot process it like other types of data. let's look at the example below.
Method
1. use count (array) to retrieve null records. 0 is returned.
2. use the is_null function
The code is as follows: |
|
$ A = array ('1', '2', '3 '); Echo count ($ ); If (is_null ($ )){ Echo '000 '; } Else { Echo & quot; 1111 & quot "; } ?>
|
The count method is feasible.
The is_null method does not work.
Instance 2
// Determine whether an array is empty
The code is as follows: |
|
/** Array ( ); Null Array ( Array ( ), Array ( ), Array ( ) ); Null Array ( Array ( ), Array ( Array ( ), Array ( 1 => 1 ) ), Array ( ) ); Not empty */ Function is_array_null ($ value) { If (empty ($ value )) { Return $ value; } Else { Return is_array ($ value )? Array_map ('Array _ Null', $ value): addslashes ($ value ); } } |
Bytes. Method 1. use cou...