Empty function, which determines that the array value is null
| The code is as follows: |
Copy code |
|
$ Arr = array ("");
$ Result = empty ($ arr );
// $ Result = false
$ Arr = array ();
$ Result = empty ($ arr );
// $ Result = true |
Implode ();
Use implode () to output the array as a string and determine whether the output string is null. It seems to be a good method at the beginning, but unfortunately it keeps up with 1.1. It won't work for arrays above two dimensions. For example:
| The code is as follows: |
Copy code |
|
$ Arr = array (), array (), array ());
$ Str = implode (',', $ arr );
If (empty ($ str) echo "null ";
Else echo "not empty "; |
Array_filter function
| The code is as follows: |
Copy code |
|
<? Php
$ Str1_array = array ('yunqi Community Network ', '', 'http: // www.111cn.net','', '123 ','');
$ Str1_array = array_filter ($ str1_array );
Print_r ($ str1_array );
?>
Result
Array
(
[0] => Yunqi Community Network
Http://www.111cn.net
[4] = & gt; 1654
) |
Count, size () function
These two functions are the method code used to judge an empty array.
$ Arr = array ("");
Echo count ($ arr );
Echo size ($ arr );
// Output 1