Home > Article > Backend Development > 求php大神帮帮忙 这段字符串怎么办·
求php大神帮帮忙 这段字符串怎么处理·
$str = "http://www.test.com/imges/1.jpg--1,http://www.test.com/imges/3.jpg--2,http://www.test.com/imges/3.jpg--3";
我想要的结果 不知道怎么写正则
$str1 = "http://www.test.com/imges/1.jpg,http://www.test.com/imges/3.jpg,http://www.test.com/imges/3.jpg";
$str2 = "1,2,3";
求高手帮帮忙
------解决方案--------------------
$str = "http://www.test.com/imges/1.jpg--1,http://www.test.com/imges/3.jpg--2,http://www.test.com/imges/3.jpg--3"; $str1= preg_replace('/--(\d+)/','',$str); preg_match_all('/--(\d+)/',$str,$m); $str2=join(',',$m[1]); <div class="clear"> </div>