Mohammad Rahmani
Mohammad Rahmani

Reputation: 237

How to replace an anchor with its inner html content?

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.

Upvotes: 0

Views: 173

Answers (2)

Seyed Morteza Mousavi
Seyed Morteza Mousavi

Reputation: 6953

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.

Upvotes: 2

codebauss
codebauss

Reputation: 176

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?

Upvotes: 1

Related Questions