将文本中的 link 替换为此 link 内的新 img 标签

Replace link in text to this link with new img tag inside

我有一些像这样的html

<span itemprop="actor" itemscope="" itemtype="http://schema.org/Person"><a rel="nofollow" href="/ru/name/shameik-moore" itemprop="url"><span itemprop="name">Шамеик Мур</span></a></span>

我需要在 link 内部 span 标签之前插入 img 标签,像这样

<span itemprop="actor" itemscope="" itemtype="http://schema.org/Person"><a rel="nofollow" href="/ru/name/shameik-moore" itemprop="url"><img src="/photo/00/04/20/42074.jpg"><span itemprop="name">Шамеик Мур</span></a></span>

我正在尝试 php 代码

$img = '<img src="/photo/00/04/20/42074.jpg">';
$actor = preg_replace('|(<a.*?>)|', ''.$img, $it);

但结果我得到了这个

<span itemprop="actor" itemscope="" itemtype="http://schema.org/Person"><img src="/photo/00/04/20/42074.jpg"><span itemprop="name">Шамеик Мур</span></a></span>

我在哪里丢了我的第一个标签? )) 请帮助我的 reg_replace 表达

给你。

$img = '<img src="/photo/00/04/20/42074.jpg">';
$actor = preg_replace('/(<a\b[^<]*>)/', '$img', $it);