$keywords = "Keyword 1, Keyword 3, Keyword 2"
$body = "This is a piece of content, there will be html code in the content"
Now it is random Extract a value from $keywords and randomly insert it into $body. I tried it myself and it inserted it into the html tag. How can I avoid inserting it into the html tag?
$len=mb_strlen($body) ;
$rad1=rand(0,$len);
$rad2=rand(0,sizeof($keywords)-1);
$s1=mb_substr ($body,0,$rad1);
$s2=mb_substr($body,$rad1,$len);
$body = $s1.$ keywords[$rad2].$s2;
Now the code is like this, please help
You can replace the html with a placeholder first.
After the random insertion is completed, replace the placeholder back to the old html