当前位置:Gxlcms > PHP教程 > 求大神一个简略的正则去除

求大神一个简略的正则去除

时间:2021-07-01 10:21:17 帮助过:20人阅读

求大神一个简单的正则去除
    Array
(
[0] => ts3.mm.bing.net/th?id=H.4877189679415314&pid=1.7&w=140&h=153&c=7&rs=1" style="height:153px;"/>
[1] => ts4.mm.bing.net/th?id=H.4541061266538791&pid=1.7&w=159&h=153&c=7&rs=1" style="height:153px;"/>
[2] => ts3.mm.bing.net/th?id=H.5012914882808678&pid=1.7&w=124&h=153&c=7&rs=1" style="height:153px;"/>
[3] => ts2.mm.bing.net/th?id=H.4755508963443465&pid=1.7&w=187&h=153&c=7&rs=1" style="height:153px;"/>
[4] => ts1.mm.bing.net/th?id=H.5001765194041784&pid=1.7&w=144&h=146&c=7&rs=1" style="height:146px;"/>
)


求大神怎么去除这个数组&之前的所有数据
例如ts3.mm.bing.net/th?id=H.4877189679415314&pid=1.7&w=140&h=153&c=7&rs=1" style="height:153px;"/>
变成ts3.mm.bing.net/th?id=H.4877189679415314

分享到:


------解决方案--------------------
明明是“后”偏要说是前
$ar = array(
'ts3.mm.bing.net/th?id=H.4877189679415314&pid=1.7&w=140&h=153&c=7&rs=1" style="height:153px;"/>',
'ts4.mm.bing.net/th?id=H.4541061266538791&pid=1.7&w=159&h=153&c=7&rs=1" style="height:153px;"/>',
'ts3.mm.bing.net/th?id=H.5012914882808678&pid=1.7&w=124&h=153&c=7&rs=1" style="height:153px;"/>',
'ts2.mm.bing.net/th?id=H.4755508963443465&pid=1.7&w=187&h=153&c=7&rs=1" style="height:153px;"/>',
'ts1.mm.bing.net/th?id=H.5001765194041784&pid=1.7&w=144&h=146&c=7&rs=1" style="height:146px;"/>',
);
$p = new ArrayIterator($ar);
$i = new RegexIterator($p, '/&.*$/', RegexIterator::REPLACE);
$i->replacement = '';

人气教程排行