preg_split kullanarak remopte url görüntüsünü bulma

1 Cevap php

i want the content inside of the "img" tag from the string. for ex:- if

str="< img src="/files/thumbnails/001.simonhiggins_comm games_thumb.jpg" title="Commonwealth Games" alt="showreel" class="clear-right-margin" />"

sonra ben aşağıdaki gibi o / p preg_split kullanarak istiyorum: -

src="/files/thumbnails/001.simonhiggins_comm games_thumb.jpg" title="Commonwealth Games" alt="showreel" class="clear-right-margin"

i bulmak için aşağıdaki kod kullanılır

$x = preg_split('/<img(.*?)>/',$p,-1,PREG_SPLIT_DELIM_CAPTURE);

but it is not working properly for some cases for ex:- if there is a space or a blank line inside the image tag.

1 Cevap

preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $data, $matches)