extract image src from text?

前端 未结 3 1533
不知归路
不知归路 2020-12-20 02:10

I have a variable $content that contains some text and images in this form (unknown amount of images):

    text text text text 

        
3条回答
  •  离开以前
    2020-12-20 02:33

    Using regex:

    text text text text
        
    text text text text text text text text text text text text text text text text text text text text
    ';
    
    
    preg_match_all('@/]*/?>@Ui', $str, $out);
    
    print_r($out[1]);
    
    ?>
    

    Output:

    Array
    (
        [0] => path/to/image/1
        [1] => path/to/image/2
        [2] => path/to/image/3
        [3] => path/to/image/4
        [4] => path/to/image/5
    )
    

提交回复
热议问题