如何使用空值传递或回显数组的键
问题描述:
New to php. Please how do you select or output from an array, all the keys with NULL or empty values?
php新手。 请问您如何从数组中选择或输出所有具有NULL或空值的键? p> div>
答
$emptyKeys = array_keys(array_filter($array, 'strlen'));
$emptyKeys
contains an array of all the keys which contain empty values.
答
suppose that u have an array
<?php
foreach($array AS $key=>$value){
if(empty($value)){
echo $key;
}
}
?>
or instead of echo
you store your keys