Home > Article > Backend Development > php 循环输出数组里元素时,空的元素不输出,怎么写
$array = array('a' => "abc", 'b' => "",'c' =>"cde",'d' =>"def",'e'=>"");
我想要的结果是:
我的abc
我的cde
我的d
$array = array('a' => "abc", 'b' => "",'c' =>"cde",'d' =>"def",'e'=>"");foreach($array as $v) { if(!empty($v)) echo "我的$v<br>";}我的abc