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
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.
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;
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"
$blurb = preg_replace('/<[^>]*>/', '', $blurb);doesnt work?