I am using strip_tags() function to extract the contents of a link (the text part not the link part). The string is obtained from twitter. Unfortunately it returns the same thing.
The code is as follows
$a = $cur['source'];
echo strip_tags($a);
Input
<a href="http://twitter.com/download/android">Twitter for Android</a>
Output
<a href="http://twitter.com/download/android">Twitter for Android</a>
When I copy pasted the input to a string and tried strip_tags its working perfectly. What could be the reason/?
You needed to use html_entity_decode because your HTML looked to be HTML, but wasn’t (in fact, all html codes were themselves encoded to other html codes).
If you try to
echo htmlentities($cur['source']), you’ll seeThis mean this string can be displayed on a browser without being interpreted as html (as a link in your case). That’s very useful if for example, I want to display
<html>on Stackoverflow without seeing my<html>tag interpreted.