0

Hi sir's outthere,i need youre help...Please

i need to strip the html tag in my record in my mysql database
here's how it look in my database
CITY Country
ADELAIDE | AUSTRALIA</td></tr></tbody></table></div><div style="clear:both; paddi

hope somebody know how to strip this tag.
i try
$country2a = strip_tags($cntry);
but it didnt work...

any help/suggestion is greatly appreciated

5
Contributors
10
Replies
17
Views
7 Years
Discussion Span
Last Post by metalix
0

you need a source for the strip_tags
try strip_tags($country, <a><p><table><tr><td><div>)

0

hmmm strip_tags($cntry); should have worked.

you can try using a function i found on the PHP Manuel LINK

<?php
function my_strip_tags($str) {
    $strs=explode('<',$str);
    $res=$strs[0];
    for($i=1;$i<count($strs);$i++)
    {
        if(!strpos($strs[$i],'>'))
            $res = $res.'&lt;'.$strs[$i];
        else
            $res = $res.'<'.$strs[$i];
    }
    return strip_tags($res);   
}
?>

hopes that helps

0

Thanks a million guys....i try all youre suggestion and it work.. now my program work very fine..i really appreciate your help.

i have 1 more question.
is there any ways that you can strip the html tag before you can insert into youre database?

my source is url, i explode it and insert into my database..but there are times that it include the hidden html tag... i try to explode it but it cant strip the hidden html tag..

this is just a follow up question, ill mark it solve later..
thanks a million times guys.

0

are you trying for this?

<?
function clean($value) {

       // If magic quotes not turned on add slashes.
       if(!get_magic_quotes_gpc())

       // Adds the slashes.
       { $value = addslashes($value); }

       // Strip any tags from the value.
       $value = strip_tags($value);

       // Return the value out of the function.
       return $value;

}
$sample = "<a href='test.php'><strong>test</strong></a>";
$sample = clean($sample);
echo $sample;
?>
0

thanks for reply sir

for example

$url = file_get_contents('http://www.example.com)
$content = explode("<td>"$url);
then $content look like this
array=>
$content[0];//it contain City
$content[1];///it contain Street
$content[2];///it contain Country...there are times that this array include the hidden html tag.. heres the record in my database
City | Country
| ADELAIDE | AUSTRALIA</td></tr></tbody></table></div><div style="clear:both; paddi |

If you take a look at country column you will see </td></tr></tbody></table></div><div style="clear:both; paddi..

how can i strip that before i insert it?

0

you can just use str_replace() before it goes in.
try this:

$string = "<strong>my font is bold & strong</strong>";
$string = str_replace('&', '&amp;', $string);
$string = str_replace('<', '&lt;', $string);
$string = str_replace('>', '&agt;', $string);

they must be in this order.
and after this you can use bbcode if need be by doing something like this:

$string = str_replace('[B]', '<strong>', $string);
$string = str_replace('[/B]', '</stong>', $string);

though i still recommend preg for bbcode

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.