Reputation: 99
I have the following html content:
<p>My name is <a href="way2project">way2project</a></p>
Now I want this text as <p>My name is way2project</p>
Is there any way to do this? Please help me thanks
I used preg_replace but in vain.
Thanks again
Upvotes: 3
Views: 5324
Reputation: 794
Checkout Simple Html Dom Parser
$html = str_get_html('<html><body>Hello!<a href="http://stackoverflow.com">SO</a></body></html>');
echo $html->find('a',0)->innertext; //prints "SO"
Upvotes: 1
Reputation: 10649
This seems strange, but not knowing the complete scope of your issue and seeing that you want to do this in PHP, you can try:
$origstring = '<p>My name is <a href="way2project">way2project</a></p>';
$newstring = str_replace('<a href="way2project">way2project</a>', 'way2project', $origstring);
echo $newstring;
Upvotes: 1
Reputation: 43810
You can use the strip tags function
$string = '<p>My name is <a href="way2project">way2project</a></p>';
echo strip_tags($string,'<p>');
note the second parameter is the list of allowed tags you wont to ignore.
Upvotes: 2