Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strip_tags()

Status
Not open for further replies.

bccamp

Technical User
Jan 20, 2005
69
I've got data that I'm trying to strip the HTML and get just the Text.
Code:
<a href="coding">Text</a>
I just want the Text, buy strip_tags is not pulling anything out. This was on the manual page:
Code:
$string = preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is', '\2 (\1)', $string);
but it doesn't work for me either.
Code:
$string=strip_tags($string)
didn't work. I've looked at the manual pages, tried the suggestions, but nothing is taking out the coding. Is there a better way, or am I missing something?

Thanks.
 
Try this:

$string = "<a href=\"coding\">Text</a>";
$string=strip_tags($string);
echo $string;
 
Thanks for the help, but I tried that coding before and it didn't work. I had the brilliant idea overnight to actually check the data coming out of the database to see what format it was in, because the data wasn't printing on the screen in link format, it was printing:
Code:
<a href="link">Text</a>
I should have realized before, but sometimes the most obvious is hardest to see. All the '<' and '>' were in the data as '&lt;' and '&gt;'. Can't believe I work hours on this and didn't see that. Solution:
I converted the htmlspecialcharacters back to '< >' then used strip_tags() to get rid of them.

Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top