0

Hello how can I replace an anchor with its inner conetent. I mean let's say I have <a someAttrs>someHtmlContent</a> and I want someHtmlContent as output using PHP.

Dancrumb
  • 26,597
  • 10
  • 74
  • 130
Mohammad Rahmani
  • 227
  • 1
  • 10

2 Answers2

2

If you have <a someAttrs>someHtmlContent</a> you can, use strip_tags() function in php to strips any tag in your string and convert to someHtmlContent.

For example:

<?php
echo strip_tags("<a someAttrs>someHtmlContent</a>");
?>

will gives you desired answer. But if you must first find the anchor tags, please refer to previews answers.

Also you can find documentation of strip_tags function here.

Seyed Morteza Mousavi
  • 6,855
  • 8
  • 43
  • 69
1

Would be good to use this library: http://simplehtmldom.sourceforge.net/manual.htm

or some of the others mentioned here: How do you parse and process HTML/XML in PHP?

Community
  • 1
  • 1
codebauss
  • 176
  • 2