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

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

go to php.net and find it there and it should give you a simple overview :)

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

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.

just give me example what you are trying

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;
?>

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?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.