Canman2005 Posted August 18, 2007 Share Posted August 18, 2007 Hi all Wonder if someone can help What I have is text for each page of my site which is stored in a sql table, to print the text on the pages I use <?php print $row['content']; ?> The following is an example of the type of content stored ------------------------------------------------ Welcome to the contact page *C* page check *C* Please use the navigation bar above ------------------------------------------------ What I want to do is to remove the section of the content which is between and including *C* page check *C* So it would just print the content as ------------------------------------------------ Welcome to the contact page Please use the navigation bar above ------------------------------------------------ Can this be done? Any help would be great Thanks in advance Dave Quote Link to comment Share on other sites More sharing options...
marcus Posted August 18, 2007 Share Posted August 18, 2007 $bad = "*C*\npage check\n*C*"; $txt = str_replace($bad,"",$row['content']); echo $txt; No idea how your code is formatted, but you get the point. Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted August 18, 2007 Author Share Posted August 18, 2007 Thanks for that, but what I meant was that it would replace anything between *C* So it would basically use them as tags, I could change them all to *C-start* and *C-end* so that it knows what the start tag is and what the end tag is can this be done in this case? Thanks again Dave Quote Link to comment Share on other sites More sharing options...
marcus Posted August 18, 2007 Share Posted August 18, 2007 Um. $string = "*C* your text here *C*"; $explode = explode("*C*",$string); $text = $explode[1]; Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted August 18, 2007 Author Share Posted August 18, 2007 Sorry, might not be making much sense. Basically I want to get rid of everything that is held between two tags, so if the page content was ----------------------- Welcome to the page *C* click here *C* ---------------------- then it would strip out the following *C* click here *C* and simply print -------------------------- welcome to the page -------------------------- does the make any sense? Thanks Quote Link to comment Share on other sites More sharing options...
marcus Posted August 18, 2007 Share Posted August 18, 2007 Lol. $string = "*C* your text here *C*"; $explode = explode("*C*",$string); $text = $explode[1]; echo str_replace($text,"",$string); that would remove "your text here" Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted August 18, 2007 Author Share Posted August 18, 2007 Cool Thanks Is there a way to firstly remove the *C* so that it isnt printed and secondly, can be it be changed so that the start tag looks like *C-start* and the end tag would look like *C-end* Thanks again Dave Quote Link to comment Share on other sites More sharing options...
Masna Posted August 18, 2007 Share Posted August 18, 2007 $content = str_replace("*C*", "", $content); and secondly, can be it be changed so that the start tag looks like *C-start* and the end tag would look like *C-end* What does it matter; you're removing it all. Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted August 18, 2007 Author Share Posted August 18, 2007 Sorry, just for easy reference really. 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.