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
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 obtain 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, but the is_null method is not.
Instance 2,Check 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 (emptyempty ($ value ))
- {
- Return $ value;
- }
- Else
- {
- Return is_array ($ value )? Array_map ('Array _ Null', $ value): addslashes ($ value );
- }
- }