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);

Need Your Help

D2: empty string in a conditional statement

d d2

In the following code, why does 2 give output but not 3? The removechars statement returns a string with length 0

Easiest way to create a Facebook application

facebook tabs

I need to create a simple tab page with custom content inside. How on earth I can get there the shortest and easiest way? Maybe I want to track the users who liked the page, but that's not compulso...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.