S
S
slava kk2020-11-09 21:15:16
PHP
slava kk, 2020-11-09 21:15:16

How to replace a link to another element in php?

It is necessary to change with regular expressions all links in a line, of the form to<a href="...">....</a>

<tr><td><span> <a href="...">....</a> </span></td></tr>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IvanIF, 2020-11-09
@slavchickalpha

$text = preg_replace('/<a\shref="([\S]+?)">([\S]+?)<\/a>/', '<tr><td><span> <a href="$1">$2</a> </span></td></tr>', $text);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question