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 Link to comment https://forums.phpfreaks.com/topic/107986-how-do-i-show-a-page-but-exclude-some-parts/ 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; ?> Link to comment https://forums.phpfreaks.com/topic/107986-how-do-i-show-a-page-but-exclude-some-parts/#findComment-553471 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! :) Link to comment https://forums.phpfreaks.com/topic/107986-how-do-i-show-a-page-but-exclude-some-parts/#findComment-553565 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.