skitchen Posted June 9, 2007 Share Posted June 9, 2007 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 More sharing options...
cooldude832 Posted June 9, 2007 Share Posted June 9, 2007 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++; } Link to comment https://forums.phpfreaks.com/topic/54901-split-html-code-to-variables/#findComment-271516 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.