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.
Asked
Active
Viewed 168 times
0

Dancrumb
- 26,597
- 10
- 74
- 130

Mohammad Rahmani
- 227
- 1
- 10
-
1possible duplicate of [How to parse and process HTML/XML with PHP?](http://stackoverflow.com/questions/3577641/how-to-parse-and-process-html-xml-with-php) – Quentin Mar 28 '13 at 13:28
-
Can you elaborate more in details; What are you going to do? You can use javascript in client side. – Seyed Morteza Mousavi Mar 28 '13 at 16:22
-
@SeyedMortezaMousavi Well, I have not thought of javascript. I prefer to delever neat HTML to my mobile app. – Mohammad Rahmani Mar 31 '13 at 14:08
2 Answers
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?