"",'c' =>"cde",'d' =>"def",'e'=>"");我想要的结果是:我的abc我的cde我的"/>  "",'c' =>"cde",'d' =>"def",'e'=>"");我想要的结果是:我的abc我的cde我的">
Home > Backend Development > PHP Tutorial > php 循环输出数组里元素时,空的元素不输出,如何写

php 循环输出数组里元素时,空的元素不输出,如何写

WBOY
Release: 2016-06-13 12:08:01
Original
1002 people have browsed it

php 循环输出数组里元素时,空的元素不输出,怎么写
$array = array('a' => "abc", 'b' => "",'c' =>"cde",'d' =>"def",'e'=>"");

我想要的结果是:

我的abc
我的cde
我的d
------解决思路----------------------

$array = array('a' => "abc", 'b' => "",'c' =>"cde",'d' =>"def",'e'=>"");<br />foreach($array as $v) {<br />  if(!empty($v)) echo "我的$v<br>";<br />}<br />
Copy after login
我的abc
我的cde
我的def

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template