explode切割foreach循环输出,加个条件 包含某字符就不输出这个组
程序员文章站
2022-06-08 11:46:12
...
$navinfor[down]='aaa$$$http://$$$ccc$$$ddd';$downzu = explode("$$$",$navinfor[down]); foreach($downzu as $k=>$v){ $downno=$k+1; echo $downno.'=';echo $v.'
';}
需要输出的是
1=aaa
2=ccc
3=ddd
条件包含http就清掉不作输出
回复讨论(解决方案)
$navinfor['down']='aaa$$$http://$$$ccc$$$ddd';$downzu = explode("$$$",$navinfor['down']);$downno = 0; foreach($downzu as $k=>$v){ if(strpos($v, 'http') !== false) continue; $downno++; echo $downno.'='; echo $v.'1=aaa
';}
2=ccc
3=ddd