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 Link to comment https://forums.phpfreaks.com/topic/65620-removing-section-of-text/ 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. Link to comment https://forums.phpfreaks.com/topic/65620-removing-section-of-text/#findComment-327687 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 Link to comment https://forums.phpfreaks.com/topic/65620-removing-section-of-text/#findComment-327696 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]; Link to comment https://forums.phpfreaks.com/topic/65620-removing-section-of-text/#findComment-327705 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 Link to comment https://forums.phpfreaks.com/topic/65620-removing-section-of-text/#findComment-327716 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" Link to comment https://forums.phpfreaks.com/topic/65620-removing-section-of-text/#findComment-327718 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 Link to comment https://forums.phpfreaks.com/topic/65620-removing-section-of-text/#findComment-327736 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. Link to comment https://forums.phpfreaks.com/topic/65620-removing-section-of-text/#findComment-327739 Share on other sites More sharing options...
Canman2005 Posted August 18, 2007 Author Share Posted August 18, 2007 Sorry, just for easy reference really. Link to comment https://forums.phpfreaks.com/topic/65620-removing-section-of-text/#findComment-327742 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.