silkAdmin
silkAdmin

Reputation: 4830

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 ?

Upvotes: 0

Views: 39

Answers (1)

Toto
Toto

Reputation: 91498

use preg_match_all instead:

preg_match_all($pattern, $html, $matches);

Upvotes: 4

Related Questions