Results 1 to 5 of 5

Thread: How to remove HTML Tags?

  1. #1

    Default How to remove HTML Tags?

    How can I remove the HTML tags from my string? Please help, I would appreciate if you could provide the code.

  2. #2

    Default

    You could use this code, it will solve your query.

    $newstring=strip_tags($oldstring);

  3. #3

    Default

    Quote Originally Posted by lester View Post
    You could use this code, it will solve your query.

    $newstring=strip_tags($oldstring);
    Thanks for your prompt help on this, however the above code strips all the characters out from between the tags as well. Is there a code by which i can retain that.

  4. #4
    Join Date
    Nov 2010
    Posts
    102

    Default

    I found the below script in one of the forum I participate normally, hope this is useful:

    // If I take the end tag off of the following line, the only word displayed is This
    $subject = 'This <script Inside the karats> can be seen';
    $tag_string = $subject;
    $comments = 'This is the comments .. <script window.open><This is not seen>This is seen.';

    $subject = strip_tags($tag_string, "<script");
    $comments = strip_tags($comments, "<script");

    echo 'Check out Subject .. no Karats ' . $subject ;
    echo '<br />';
    echo '<br />';
    echo 'Check out Comments .. no Karats ' . $comments ;

  5. #5
    Join Date
    Dec 2010
    Posts
    5

    Default

    Thanks. Example of PHP site:
    Code:
    <?php
    $text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
    echo strip_tags($text);
    echo "\n";
    
    // Allow <p> and <a>
    echo strip_tags($text, '<p><a>');
    ?>

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •