View Full Version : preg_match_all pattern question #2

07-12-2007, 10:12 PM
i really do not understand this.
this should be extremely simple yet it is not working...

i have this text:

$text = '


and i want to split it into two arrays. both the contents of the insides of the <td></td>.

patterns i have tried:

$pattern = "/<td>(.*)<\/td>/";
$pattern = "/\<td\>(.*)\<\/td\>/";

and then:


and that will always return an empty array... i dont understand why.

07-12-2007, 10:21 PM
Try this for your pattern.

$pattern = "/<td.*?>.*?<\/td>/xmsi";
That will catch td cells that also have ids or classes on them.

11-01-2009, 10:56 PM
I am getting stuck with similar problem. Say if I have many table rows like the followings

<tr title="abc"><td>...</td></tr>
<tr title="def"><td>...</td></tr>
<tr title="def"><td>...</td></tr>

How can I extract on those tr with title = "abc"?

Thanks for any help