opencombatclan Posted September 21, 2008 Share Posted September 21, 2008 Hi all, I have a HTML page and php page that captures the HTML pages content. The Html page contains a time table, lets say it contains: <TABLE><TR><TD width="33%" nowrap=1><font size="2" face="Arial"> en </font> </TD> <TD width="33%" nowrap=1><font size="2" face="Arial"> <i>103 </i></font> </TD> <TD width="33%" nowrap=1><font size="2" face="Arial"> <B>CBY</B> </font> </TD> </TR></TABLE></TD> <TD align=center nowrap=1 bgcolor="#FFFF00" ><TABLE><TR><TD width="33%" bgcolor="#FFFF00" nowrap=1><font size="2" face="Arial" color="#000000"> te7. </font> </TD> <TD width="33%" bgcolor="#FFFF00" nowrap=1><font size="2" face="Arial" color="#000000"> <i>007 </i></font> </TD> <TD width="33%" bgcolor="#FFFF00" nowrap=1><font size="2" face="Arial" color="#000000"> <B>KUY</B> </font> </TD> </TR><TR><TD width="33%" nowrap=1><font size="2" face="Arial"> bi7 </font> </TD> <TD width="33%" nowrap=1><font size="2" face="Arial"> <i>011 </i></font> </TD> <TD width="33%" nowrap=1><font size="2" face="Arial"> STU </font> </TD> </TR> I want to personalize the time table, and i made a php script that give you sevral options. For example i want to remove "bi7" (as shown in html code) but bi7 is room 011 from teacher: STU Lets say i dont need bi7 in my time table, so i want my script to remove it. I got the complete Html page (with table) in my $data var. And i created a option to choose, lets say if its set to 1 you need bi7, and if its set to 0 you want bi7 to be removed from your timtable. But when you remove bi7, also the teacher (STU) and the room (001) needs to be removed. Since the rooms are always different the PHP code needs to be smart. i taught of: Let the PHP code search for: "bi7" When its there it makes a selection from the nearest <tr> till the nearest </tr> (its <tr> data bi7 data </tr>) Then it replaces that selection by <!-- removed --> or so So when i for example: echo $data, and i choosed to delete bi7 I will get the output: <TABLE><TR><TD width="33%" nowrap=1><font size="2" face="Arial"> en </font> </TD> <TD width="33%" nowrap=1><font size="2" face="Arial"> <i>103 </i></font> </TD> <TD width="33%" nowrap=1><font size="2" face="Arial"> <B>CBY</B> </font> </TD> </TR></TABLE></TD> <TD align=center nowrap=1 bgcolor="#FFFF00" ><TABLE><TR><TD width="33%" bgcolor="#FFFF00" nowrap=1><font size="2" face="Arial" color="#000000"> te7. </font> </TD> <TD width="33%" bgcolor="#FFFF00" nowrap=1><font size="2" face="Arial" color="#000000"> <i>007 </i></font> </TD> <TD width="33%" bgcolor="#FFFF00" nowrap=1><font size="2" face="Arial" color="#000000"> <B>KUY</B> </font> </TD> </TR> <!-- removed --> I really hope my big idea is clear, and i really need it to work, but i dont know how to delete the specific selection (as i describled above) Please help me out, yours faithfully, steven Link to comment https://forums.phpfreaks.com/topic/125189-manipulating-a-string/ Share on other sites More sharing options...
effigy Posted September 22, 2008 Share Posted September 22, 2008 How about parsing the table into a data structure, modifying the structure, then dumping the structure back into a table format? Link to comment https://forums.phpfreaks.com/topic/125189-manipulating-a-string/#findComment-647706 Share on other sites More sharing options...
opencombatclan Posted September 24, 2008 Author Share Posted September 24, 2008 Hmm, maybe a good idea, but how? i really dont have a single idea of how to do it. Can you help me out? (or someone else?) Link to comment https://forums.phpfreaks.com/topic/125189-manipulating-a-string/#findComment-649737 Share on other sites More sharing options...
Barand Posted September 24, 2008 Share Posted September 24, 2008 That's if you could get it to parse successfully, but with /TABLE tags in the middle of the cells, I don't hold out much hope. Link to comment https://forums.phpfreaks.com/topic/125189-manipulating-a-string/#findComment-649819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.