亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

php - How to take out multiple src paths in the string below
黃舟
黃舟 2017-06-27 09:18:07
0
5
1039

The 20170626/1498445461112119.png (date/file name) path after taking out image/ is also ok. I can manually spell the previous one. . .

I'm sorry that I can't adopt more than one. I logged in to segmentfault after taking them out. Thank you very much.

With regular rules: $preg='//d/d.[jpg|jpeg|png|bmp|gif]*/i';

黃舟
黃舟

人生最曼妙的風(fēng)景,竟是內(nèi)心的淡定與從容!

reply all(5)
洪濤
<?php
$str = '<p>圖1<img src="/public/upload/ueditor/image/20170626/1234567890.png" title="1234567890.png" alt="QQ圖片1234567890.png"></p><p>圖1<img src="/public/upload/ueditor/image/20170626/0987654321.png" title="0987654321.png" alt="QQ圖片0987654321.png"></p>';

if (preg_match_all('/src="(.+?)"/', $str, $matches)) {
    print_r($matches);
} else {
    echo '沒有匹配';
}

Output:

(
    [0] => Array
        (
            [0] => src="/public/upload/ueditor/image/20170626/1234567890.png"
            [1] => src="/public/upload/ueditor/image/20170626/0987654321.png"
        )

    [1] => Array
        (
            [0] => /public/upload/ueditor/image/20170626/1234567890.png
            [1] => /public/upload/ueditor/image/20170626/0987654321.png
        )

)

If you are interested, please watch my introductory lecture on regular expressions: Learn to use regular expressions in one hour

伊謝爾倫

Regular expressions are more convenient

小葫蘆

Use regular matching, and then use ()to extract the piece as a subset

伊謝爾倫
$str = "<img src='/public/upload/ueditor/image/20170601/32462374327846.png'><img src='/public/upload/ueditor/image/201611111/989384328.jpeg'><img src='/public/upload/ueditor/image/20160808/7874873284.gif'>";

preg_match_all("/image\/(\d+\/\w+\.(png|jpeg|gif|jpg))/", $str, $matches);
學(xué)習(xí)ing
<?php
define('CLI_SCRIPT', true);

$tt = '<p><img class="icon" alt="141220154.zip" title="141220154.zip" src="http://11111/theme/image.php/ gourmet/core/1491882323/f/archive" /> </p><p><img class="icon" alt="141220154.zip" title="141220154.zip" src="http://3333/theme/image.php/gourmet/core/         1491882323/f/archive" /></p>';

preg_match_all('/<img [^>]*src=\"(.+?)\"/', $tt, $matches);                                                                                                                 
var_dump($matches);    // 需要的字符串在$matches[1]中,具體信息可以打印了看

Reference link: http://php.net/manual/zh/func...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template