REGEX and PHP, cant not matches multiple expressions
I am trying to get all the <img> on a html page. I am using the following code:
$pattern = '/<im\w+\s+[^>]*>/'; preg_match($pattern, $html, $matches);
Some how this works but $matches array is only hodling the latest occurence of my selection (i was expeting to have as many index in that array as i have instances of the matched selection)
Am i doing something worng ?
Answers
use preg_match_all instead:
preg_match_all($pattern, $html, $matches);