这个数组如何用for循环出来
Jun 23, 2016 pm 01:39 PM 记住,前提必须是for循环,不要别的方法循环,切记!
Array
(
[0] => /dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50e9c339938f7f013cc1170a321f6458.jpg::::::/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50e9c339938f7f013cc1170a321f6458.jpg::::::
[1] => /dgcms/d/file/product/yysj/gdjcpt/2015-02-15/71d522fdc9305d0d6f4cc6735e8035c4.jpg::::::/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/71d522fdc9305d0d6f4cc6735e8035c4.jpg::::::
[2] => /dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50700eff01cc0fd13fdbfe8cc0863222.jpg::::::/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50700eff01cc0fd13fdbfe8cc0863222.jpg::::::
)
我只想循环出这个二维数组中的每一组数组中的第一个,
回复讨论(解决方案)
??是一???。
估?你是要??效果。
$arr = array( '/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50e9c339938f7f013cc1170a321f6458.jpg::::::/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50e9c339938f7f013cc1170a321f6458.jpg::::::', '/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/71d522fdc9305d0d6f4cc6735e8035c4.jpg::::::/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/71d522fdc9305d0d6f4cc6735e8035c4.jpg::::::', '/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50700eff01cc0fd13fdbfe8cc0863222.jpg::::::/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50700eff01cc0fd13fdbfe8cc0863222.jpg::::::');for($i=0,$len=count($arr); $i<$len; $i++){ $tmp = explode('::::::', $arr[$i]); echo $tmp[0].'<br>';}
/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50e9c339938f7f013cc1170a321f6458.jpg
/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/71d522fdc9305d0d6f4cc6735e8035c4.jpg
/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50700eff01cc0fd13fdbfe8cc0863222.jpg
??是一???。
估?你是要??效果。
$arr = array( '/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50e9c339938f7f013cc1170a321f6458.jpg::::::/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50e9c339938f7f013cc1170a321f6458.jpg::::::', '/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/71d522fdc9305d0d6f4cc6735e8035c4.jpg::::::/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/71d522fdc9305d0d6f4cc6735e8035c4.jpg::::::', '/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50700eff01cc0fd13fdbfe8cc0863222.jpg::::::/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50700eff01cc0fd13fdbfe8cc0863222.jpg::::::');for($i=0,$len=count($arr); $i<$len; $i++){ $tmp = explode('::::::', $arr[$i]); echo $tmp[0].'<br>';}
/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50e9c339938f7f013cc1170a321f6458.jpg
/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/71d522fdc9305d0d6f4cc6735e8035c4.jpg
/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50700eff01cc0fd13fdbfe8cc0863222.jpg
具体到实际问题
为啥我也是这样写的,只能输出一个图片呢
<?phpif($bqr['morepic']){$morepic=$bqr['morepic'];$rexp="rn";$fexp="::::::";$rr=explode($rexp,$morepic);$count=count($rr);$morpic="";for($i=0;$i<$count;$i++){$j=$i+1;$fr=explode($fexp,$rr[$i]);$smallpic=$fr[0]; //小图$bigpic=$fr[1]; //大图 $morpic .="<li class='active'><i></i><img src='".$smallpic."' style="max-width:90%" style="max-width:90%" alt="这个数组如何用for循环出来" ><b></b></li>"; } echo $morpic;}?>
$rexp="rn";
??是一???。
估?你是要??效果。
$arr = array( '/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50e9c339938f7f013cc1170a321f6458.jpg::::::/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50e9c339938f7f013cc1170a321f6458.jpg::::::', '/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/71d522fdc9305d0d6f4cc6735e8035c4.jpg::::::/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/71d522fdc9305d0d6f4cc6735e8035c4.jpg::::::', '/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50700eff01cc0fd13fdbfe8cc0863222.jpg::::::/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50700eff01cc0fd13fdbfe8cc0863222.jpg::::::');for($i=0,$len=count($arr); $i<$len; $i++){ $tmp = explode('::::::', $arr[$i]); echo $tmp[0].'<br>';}
/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50e9c339938f7f013cc1170a321f6458.jpg
/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/71d522fdc9305d0d6f4cc6735e8035c4.jpg
/dgcms/d/file/product/yysj/gdjcpt/2015-02-15/50700eff01cc0fd13fdbfe8cc0863222.jpg
具体到实际问题
为啥我也是这样写的,只能输出一个图片呢
<?phpif($bqr['morepic']){$morepic=$bqr['morepic'];$rexp="rn";$fexp="::::::";$rr=explode($rexp,$morepic);$count=count($rr);$morpic="";for($i=0;$i<$count;$i++){$j=$i+1;$fr=explode($fexp,$rr[$i]);$smallpic=$fr[0]; //小图$bigpic=$fr[1]; //大图 $morpic .="<li class='active'><i></i><img src='".$smallpic."' style="max-width:90%" style="max-width:90%" alt="这个数组如何用for循环出来" ><b></b></li>"; } echo $morpic;}?>
你的$rexp="rn"; 是$rexp="\r\n"; 吗? 用rn分割,你确定图片地址中不会出现 rn?

热门文章

热门文章

热门文章标签

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)