I'd like to be able to return an array with a list of all images (src="" values) from html
[0] = "images/header.jpg" [1] = "images/person.jpg"
is there a regular expression that can do this?
Many thanks in advance!
I'd like to be able to return an array with a list of all images (src="" values) from html
[0] = "images/header.jpg" [1] = "images/person.jpg"
is there a regular expression that can do this?
Many thanks in advance!
/src="([^"]+)"/
The image will be in group 1.
Example:
preg_match_all('/src="([^"]+)"/', '<img src="lol"><img src="wat">', $arr, PREG_PATTERN_ORDER);
Returns:
Array
(
[0] => Array
(
[0] => src="lol"
[1] => src="wat"
)
[1] => Array
(
[0] => lol
[1] => wat
)
)