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 count (array) to retrieve null records. 0 is returned.
2. Use the is_null Function
The Code is as follows: |
Copy code |
<? Php $ 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: |
Copy code |
/** 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 ); } } |