Jump to content

Manipulating a string


opencombatclan

Recommended Posts

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

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.