热搜:NVER node 开发 php

explode切割foreach循环输出,加个条件 包含某字符就不输出这个组

2024-07-27 09:35:01
explode切割foreach循环输出,加个条件 包含某字符就不输出这个组

$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