preg_match_all help
Posted: Mon Jan 21, 2008 11:52 pm
I'm no genius when it comes to regex, so I would appreciate a little help.
Which prints this:
Thanks.
edit:
meh...forgot there was a regex forum for these questions
Code: Select all
<?php
$content = '<td><p>501</p></td>
<td><p>2,633</p></td>
<td><p>2,398</p></td>
<td><p>1.1</p></td>
<td><p>12</p></td>
<td><p>373</p></td>
<td><p>147</p></td>
<td><p><img src="img.png" /></p></p></td>';
preg_match_all('/<td><p>(.*?)<\/p><\/td>/', $content, $matches);
print_r($matches);
?>I just want this:Array
(
[0] => Array
(
[0] => <td><p>501</p></td>
[1] => <td><p>2,633</p></td>
[2] => <td><p>2,398</p></td>
[3] => <td><p>1.1</p></td>
[4] => <td><p>12</p></td>
[5] => <td><p>373</p></td>
[6] => <td><p>147</p></td>
[7] => <td><p><img src="img.png" /></p></p></td>
)
[1] => Array
(
[0] => 501
[1] => 2,633
[2] => 2,398
[3] => 1.1
[4] => 12
[5] => 373
[6] => 147
[7] => <img src="img.png" /></p>
)
)
All help is appreciated.Array
(
[0] => Array
(
[0] => 501
[1] => 2,633
[2] => 2,398
[3] => 1.1
[4] => 12
[5] => 373
[6] => 147
[7] => <img src="img.png" /></p>
)
)
Thanks.
edit:
meh...forgot there was a regex forum for these questions