Split HTML Code to Variables

Hi there

Wondering if you could help with the following please.

I have this code and want to be able to split each line of it into 2 variables - one with the type of info (ie: email address) and the other with the actual info itself. This is how the info is emailed in and it cant be changed so I need to know how to split it up so that I can post the relevant bits to the mysql db.

<td class=TableText valign=top width=150>title</td>
<td class=TableText width=350>MR</td></tr>
<tr>
<td class=TableText valign=top width=150>first name</td>
<td class=TableText width=350>JOHN</td></tr>
<tr>
<td class=TableText valign=top width=150>surname</td>
<td class=TableText width=350>SMITH</td></tr>
<tr>
<td class=TableText valign=top width=150>email address</td>
<td class=TableText width=350>[email protected]</td></tr>
<tr>
<td class=TableText valign=top width=150>telephone</td>
<td class=TableText width=350>0123456789</td></tr>

Thank you!!

If I understand what you’re asking, you’re trying to parse this code. I’m afraid Regex is the way to go (unless you’re a masochist and like writing code with LOTS 'n LOTS of str_replace, strlen, strstr and substr).

Sponsor our Newsletter | Privacy Policy | Terms of Service