4
4
4ipS2015-09-26 11:22:11
PHP
4ipS, 2015-09-26 11:22:11

How to remove extra links in a line?

Hello.
There is a line of text:

<p>алвоп <a href="#"></a> и <a href="#"><img src="http://" alt=""></a></p>

using regular expressions, I try to remove links
preg_replace('#<a.*>.*</a>#USi', '', $text)
, it removes links, but I need to remove only those links that do not have images inside.
Thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Schoolboy., 2015-09-26
@viphorizon

Long code, but try to remove <a.*>it </a>separately.

$text = preg_replace('#<a.*>#USi', '', $text);
$text = preg_replace('#</a>#USi', '', $text);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question