Rinzler
Rinzler

Reputation: 2116

how to remove speacial characters from a string in php?

i am working on a php site

from the admin panel i am updating the data of content to be shown on a page using wysig editor

which add <p> </p> by default has opening and closing tags while inserting in mysql table

and when i show it on pages it comes has

        <?> with some black bakground

along the content why so how can i remove or filter it dynamically while pulling records

for example

      // content goes in to website
      $ a = "<p> this content </p>" ;

i wana display it has

         "this content" 

any help will be appreciated

Upvotes: 2

Views: 301

Answers (4)

Vishal
Vishal

Reputation: 2181

This will help you:

$string = "<h1>Heading</h1>"
$string = strip_tags($string);
$echo $tstring; // output ==> Heading

Upvotes: 1

Yoshi
Yoshi

Reputation: 54649

I'm taking a wild guess and assume you're using TincMCE, if so, have a look at forced_root_block setting. This is probably set to p.

http://www.tinymce.com/wiki.php/Configuration:forced_root_block

If you really want to go the php-way, then use one of the other answers ;)

Upvotes: 1

Simone
Simone

Reputation: 21272

If you only need to remove HTML tags, you should use strip_tags().

http://php.net/manual/en/function.strip-tags.php

Upvotes: 1

Query Master
Query Master

Reputation: 7097

Try This

$a = "<p> this content </p>" ;
$var = strip_tags($a);
echo $var

Upvotes: 6

Related Questions