|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need help modifiying a html document
I have a PHP problem I hope that someone may be able to help me.
I need to modifiy a html document string by striping out certain html tags residing [outside of], [html] hightlighted <?php ?> PHP script tags. i.e. (<\?) == <? (\?<); == ?> $str=" <p>I am a html string of text I must be parsed</p><br> <?php print"I am highlighted html php code and I must not be parsed or effected by the expression"; ?< I am a another html string of text and I must be parsed <?php print"I am more html php code"; ?< etc... "; I am unsure how to write a Regular Expression or use string macthing to do this. Any ideas? Gregory |
|
#2
|
|||
|
|||
|
for the regular expression, you just want to find what's between the <?php and ?<, so you can use
PHP Code:
Last edited by crazytrain81 : November 20th, 2002 at 04:47 PM. |
|
#3
|
|||
|
|||
|
crazytrain81
I'm sure that I can do this in PHP. I just don't know how :) The code below works if <?php and ?> will appear on their own line in a file. If they are embedded in a line like this then this will not work: PHP Code:
I need to modify the code below to work for those cases as well any idea on how I can do this? The test file should really also be in a string as it is not a remote file... Or maybe I could use PHP Code:
To skip over the highlighted php html code and then strip all the tags out side of it. Greg :o) Here is the test file: <html> <head><title>test document</title></head> <body> <h2>Title here</h2> <?php echo "hello world 1"; ?> <h3>Subtitle here</h3> <?php echo "hello world 2"; ?> </body> </html> PHP Code:
Last edited by retr0 : November 21st, 2002 at 07:40 AM. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Need help modifiying a html document |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|