Jump to content

Split HTML Code to Variables


skitchen

Recommended Posts

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!!

Link to comment
https://forums.phpfreaks.com/topic/54901-split-html-code-to-variables/
Share on other sites

First I would strip all the title headings saying a simple string replace <td class=TableText valign=top width=150>title</td> and first name, sirname etc etc

then I would suggeest stripping away all the </td> and the </tr> from it.  then  I would explode it at the <tr> that would create an array where $array[0] = Titlte, $array[1] would be First names, $array[2] be surname etc etc.  Then for each of those explode then at <td clss=TableText width=350> then you can just simply say

while (ISSET($title[$i])
{
insert($title[$i],$name[$i],etce,etc);
$i++;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.