There is a variable that contains a trace. text:

<a href="/some_link" some-tags="">Some text</a> 

i.e. echo $text displays <a href="/some_link" some-tags="">Some text</a>

It can also contain more text, for example:

 <a href="/some_link" some-tags="">Some text</a> <a href="/some_link_2" some-tags="">Some text 2</a> 

It is necessary to wrap the text inside these links in <span> using PHP to make it

 <a href="/some_link" some-tags=""><span>Some text</span></a> 

etc.

    2 answers 2

    C using regular, you can:

     $url= '<a href="/some_link_2" some-tags="">Some text 2</a>'; echo preg_replace('/<a(.+?)>(.+?)<\/a>/i', '<a$1><span>$2</span></a>', $url); 

      It is possible so:

       <?php $text = '<a href="/some_link" some-tags="">Some text</a>'; echo explode('>', $text)[0].'><span>'.explode('>', explode('<', $text)[1])[1].'</span><'.explode('<', $text)[1]; ?> 
      • no, apparently I did not ask the right question, a minute - Vanya Nizamov
      • updated the question) - Vanya Nizamov
      • @ VanyaNizamov, but this is of course hard what I wrote, for a long time it worked with php .. I don’t really remember regular expressions. However, this is one of the options. - nick