Hey FraT,
it normally should work like you expect it. So the replacement should prefer “SEO services” over “SEO”, if you have both active.
As we do not support self-linking atm: Could you check if your keyword “SEO services” does link to the same page, where it appears?
Thanks
Thread Starter
FraT
(@frat)
Hi Webraketen,
I can replicate the issue with the code below:
<?php
use html_changer\HtmlChanger;
require 'vendor/autoload.php';
$text = 'lorem ipsum SEO services SEO services lorem ipsum';
$search = array (
'seo' => array (
'caseInsensitive' => true,
'wordBoundary' => false,
'value' => 5,
'group' => '53',
'maxCount' => 1,
),
'seo services' => array (
'caseInsensitive' => true,
'wordBoundary' => false,
'value' => 5,
'group' => '53',
'maxCount' => 1,
),
);
$htmlChanger = new HtmlChanger($text, [
'search' => $search,
'ignore' => [
'a', // links
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', // headlines
]
]);
$htmlChanger->replace(function($text, $value){
echo $text;
});
The aspected result of the echo
is “SEO services” but it outputs “SEO”. Removing the ‘group’ fields or increasing the ‘maxCount’ the output is “SEO services”.
I hope this helps.
We’ll have a look at that. Thanks a lot!