denhamd2 Posted December 19, 2012 Share Posted December 19, 2012 Hi, I'm trying to take the content from table rows and reformat it. You can see a sample structure of the HTML below: <table><tr> <td class="fixData" align="right" width="40%">Team 1</td><td class="fixData" align="center" width="10%"> v </td><td class="fixData" align="left" width="40%">Team 2</td> <td class="fixData" align="right" width="10%"><a href="#">Results</a></td> </tr><tr> <td class="fixData" align="right" width="40%">Team 3</td><td class="fixData" align="center" width="10%"> v </td><td class="fixData" align="left" width="40%">Team 4</td> <td class="fixData" align="right" width="10%"><a href="#">Results</a></td> </tr></table> I'm trying to change it to: <tr> <td class="newfixData"><a href="result.php?Team1-Team2">Team 1 v Team 2</a></td> </tr> Any ideas how I could do this? Link to comment https://forums.phpfreaks.com/topic/272181-reformatting-the-contents-of-table-rows/ Share on other sites More sharing options...
Muddy_Funster Posted December 19, 2012 Share Posted December 19, 2012 search and replace? Link to comment https://forums.phpfreaks.com/topic/272181-reformatting-the-contents-of-table-rows/#findComment-1400301 Share on other sites More sharing options...
denhamd2 Posted December 19, 2012 Author Share Posted December 19, 2012 Hi Sorry I'm a bit of a newb. Would you be able to explain more? Just a little confused, sorry Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/272181-reformatting-the-contents-of-table-rows/#findComment-1400306 Share on other sites More sharing options...
Jessica Posted December 19, 2012 Share Posted December 19, 2012 You'll want to use a Dom parser Link to comment https://forums.phpfreaks.com/topic/272181-reformatting-the-contents-of-table-rows/#findComment-1400307 Share on other sites More sharing options...
Christian F. Posted December 19, 2012 Share Posted December 19, 2012 If the HTML code is something you control, then use an editor that can do a "search and replace" operation on the document. As Muddy_Funster so succinctly stated in his post. If you do not control the HTML code, then you'll need DOMducoment or similar. Have it parse the document, find the relevant HTML elements, draw the text you want from them, and then add it to a new string. Just like what Jessica[/]b said, equally succinctly. Link to comment https://forums.phpfreaks.com/topic/272181-reformatting-the-contents-of-table-rows/#findComment-1400337 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.