OM2 Posted May 30, 2008 Share Posted May 30, 2008 I want to show a web page I have, but exclude some parts. I want to parse this through PHP and output everytning apart from the exluded. Let me show by example what I want. Let's say i have the following code in my html file: <html><head><title></title></head> <body> Hello 123 <!-- DONT SHOW START --> Spiderman <!-- DONT SHOW END --> </body> </html> i want to be able to show this same page except when i don't want to show anything between <!-- DONT SHOW START --> and <!-- DONT SHOW END --> how do i do this? i know i can replace everything in between the markers by doing a preg_replace: but what i'm confused about is how to show th eoutput in a browser? thanks. om Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted May 30, 2008 Share Posted May 30, 2008 Something like this? <?php $page = file_get_contents('yourfile.html'); $page = preg_replace('|<!-- DONT SHOW START -->.*?<!-- DONT SHOW END -->|is','',$page); echo $page; ?> Quote Link to comment Share on other sites More sharing options...
OM2 Posted May 30, 2008 Author Share Posted May 30, 2008 yeee ha! thank u! that looks as though it does exactly what i want! :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.