shahzad Posted December 17, 2009 Share Posted December 17, 2009 i am using tiny_mce as a text editor for my CMS. buy now the problem is it add <p> tag with data so while retrieving the data for front end i get an extra space. so there is any why that i can remove <p> </p> from first paragraph. i tried using strip_tags()... but it strip all the others tag like <br> etc etc.. Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 17, 2009 Share Posted December 17, 2009 strip_tags($text, '<a>'); like this you can mention which tags you want to allow and they will not get striped. http://php.net/manual/en/function.strip-tags.php vineet Quote Link to comment Share on other sites More sharing options...
Deoctor Posted December 17, 2009 Share Posted December 17, 2009 Try using the codelobster as the editor.. the one which u are using an Javascript HTML WYSIWYG editor Quote Link to comment Share on other sites More sharing options...
shahzad Posted December 17, 2009 Author Share Posted December 17, 2009 but in my case sample data is like <p> some data </p> <p> some data </p><br> <p> some data </p> so i want <p> tag and <br> tag later in data but i dont want first <p> </p> tag.. Quote Link to comment Share on other sites More sharing options...
cags Posted December 17, 2009 Share Posted December 17, 2009 Not sure it's the best way, but this should work... $ouput = preg_replace(array('#<p>#', '#</p>#'), '', $input, 1); Quote Link to comment Share on other sites More sharing options...
shahzad Posted December 17, 2009 Author Share Posted December 17, 2009 i tried this way but it didnt work $input = $query_data['PageContent']; $ouput = preg_replace(array('#<p>#', '#</p>#'), '', $input, 1); echo $output; so i tried like this its working fine. but is it the good to do? $outout = str_replace("</p>","<br />",str_replace("<p>", "", "$query_data[PageContent]")); echo $output; Quote Link to comment Share on other sites More sharing options...
cags Posted December 17, 2009 Share Posted December 17, 2009 That doesn't do what you asked for. You said you wanted to keep everything but the first set of <p></p> tags, your code removes them all. As far as I can tell the code I gave you, given the example input you gave does exactly what you asked for. 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.