Article keywords plus links how to exclude keywords include each other?

<?php
$body = "

"" <h1>?</h1> <img src="https://example.com/test.jpg" title=""/>

"; $keywords = [ ["id"=>1,"title"=>"","url"=>"https://www.example.com/gaimingzi.html"], ["id"=>2,"title"=>"","url"=>"https://www.example.com/mingzi.html"], ["id"=>3,"title"=>"","url"=>"https://www.example.com/duanshipin.html"], ]; foreach ($keywords as $keyword) { $body = preg_replace("/(>[^<>]*?)(" . $keyword["title"] . ")([^<>]*?<)/", "$1<a href="". $keyword["url"]. "" target="_blank">$2</a>$3", $body,1); } echo $body;

from the tags database. When adding articles, there is no processing of keywords, only in the article details page to do the above processing.

Menu