<p><img class="m-4" src="../../../img/page/temp/dd2b0a2c5925e4f55da1992456eb9ef8.webp" alt="" width="295" height="360"></p>
$pattern = 'img\/page\/temp';
$replacement = 'img/page/' . $id;
$htmlText = '<p><img class="m-4" src="../../../img/page/temp/dd2b0a2c5925e4f55da1992456eb9ef8.webp" alt="" width="295" height="360"></p>'
$newHtmlText = preg_replace($pattern, $replacement, $htmlText);