Using preg_replace - HTML parse.
Posted: Thu Jun 05, 2008 5:11 am
Hi guys.
I have programmed for 3 years and i still dont understand the preg_* functions that well..
I am just wondering if someone could help me out.
Say i got this HTML code:
How exactly could i parse this so i can get the array ?
I have like tried preg_replace with like
preg_replace();
But i allways fail. Anyone?
I have programmed for 3 years and i still dont understand the preg_* functions that well..
I am just wondering if someone could help me out.
Say i got this HTML code:
Code: Select all
<html>
<head></head>
<body>
<table>
<tr>
<td>Item</td>
<td>Value</td>
</tr>
<tr>
<td>Boxer shorts</td>
<td>20USD</td>
</tr>
<tr>
<td>T-shirt</td>
<td>30USD</td>
</tr>
<tr>
<td>Pants</td>
<td>54USD</td>
</tr>
</table>
</body>
</html>
Code: Select all
$array = array(
0 => array(
0 => 'Boxer shorts',
1 => '20USD'
),
1 => array(
0 => 'T-shirt',
1 => '30USD'
),
2 => array(
0 => 'Pants',
1 => '54USD'
),
);
preg_replace();
But i allways fail. Anyone?