Home > Backend Development > PHP Tutorial > 求php大神帮帮忙 这段字符串怎么办·

求php大神帮帮忙 这段字符串怎么办·

WBOY
Release: 2016-06-13 13:09:30
Original
746 people have browsed it

求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";

求高手帮帮忙

------解决方案--------------------

PHP code
$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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template