<code>$pet = array(["name"]=>array('','','')["age"]=>array('','','')); if($pet){ echo $pet } 具体代码如上,当数组有值时,才输出。 本人用if 判断失败。</code>
<code>$pet = array(["name"]=>array('','','')["age"]=>array('','','')); if($pet){ echo $pet } 具体代码如上,当数组有值时,才输出。 本人用if 判断失败。</code>
<code>$pet = array("name"=>array('','',''),"age"=>array('','','')); foreach($pet as $pKey => $pVal){ $pet[$pKey] = array_filter($pVal); } $pet = array_filter($pet); if(!empty($pet)){ var_dump($pet); } </code>
Is this the main point of the question?
1, code error,
<code>name和age是二维数组的key,之间要逗号隔开。 $pet = array(["name"]=>array('','',''),["age"]=>array('','','')); if($pet){ echo $pet } </code>
2. When you say "the array is output only when it has a value", does it mean $pet, or name or age.
<code>array_filter过滤一下空数组。 </code>