note 100666 deleted from function.empty by cmb
| From: | cmb@php.net | Date: | Fri, 26 Apr 2019 16:55:52 +0000 |
| Subject: | note 100666 deleted from function.empty by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210681@lists.php.net to get a copy of this message | ||
Note Submitter: serkons at yahoo dot com
----
Hi you can check the status of multiple array or any variable is empty with below code.
<?php
$microtimeref = microtime ( true );
//$variable=null; // false,true,0,''
//$variable = array ('id' => 10, 'name' => 'serkon' );
$variable = array (array (0) );
echo '<pre>';
function getArray($dizi) {
foreach ( $dizi as $value )
return $value;
}
function isEmpty($array) {
if (is_array ( $array )) {
$dizi = getArray ( $array );
if (is_array ( $dizi ))
$ref = isEmpty ( $dizi );
else
if (strlen ( $dizi ) >= 1)
return false;
else
return true;
}
else
if (strlen ( $array ) >= 1)
return false;
else
return true;
if ($ref === false)
return false;
else
return true;
}
$sonuc = isEmpty ( $variable );
var_dump ( $sonuc );
echo "Total time: <b>" . round ( microtime ( true ) - $microtimeref, 4 ) .
's</b><br />';
echo '</pre>';
?>
Response:
bool(false) // not empty
Total time: 0s