是否为空函数改造来函数来源于php手册http://php.net/manual/zh/function.empty.php 无 ?php//是否为空 可判断多维数组 默认0认为非空 $type=1时0认为空function is_empty($multiarray,$type='') { if(is_array($multiarray) and !empty($multiarray)){ $tmp
是否为空函数改造 来函数来源于php手册http://php.net/manual/zh/function.empty.php
<?php
//是否为空 可判断多维数组 默认0认为非空 $type=1时0认为空
function is_empty($multiarray,$type='') {
if(is_array($multiarray) and !empty($multiarray)){
$tmp = array_shift($multiarray);
if(!is_empty($multiarray) or !is_empty($tmp)){return false;}
return true;
}
if(is_numeric($multiarray) && empty($type)){return false;}//当type为空时 视0为非空
if(empty($multiarray)){return true;}
return false;
}
//是否为空 可判断字符和一维数组 0认为非空
function is_blank($value) {
return empty($value) && !is_numeric($value);
}
$testCase = array (
0 => '',
1 => "",
2 => null,
3 => array(),
4 => array(array()),
5 => array(array(array(array(array())))),
6 => array(array(), array(), array(), array(), array()),
7 => array(array(array(), array()), array(array(array(array(array(array(), array())))))),
8 => array(null),
9 => 'not empty',
10 => "not empty",
11 => array(array("not empty")),
12 => array(array(),array("not empty"),array(array())),
12 => '0'
);
foreach ($testCase as $key => $case ) {
echo "$key is_empty= ".is_empty($case)."<br>";
}
foreach ($testCase as $key => $case ) {
echo "$key is_empty= ".is_blank($case)."<br>";
}
?>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号