here is the code I have written
<?php
$response = file_get_contents('like.json');
$arr =json_decode($response);
foreach($arr->likes->data as $category){
$findme = $category->name;
$search = 'Lets play Cricket today, what do you say about playing Bangladesh cricket CHI?';
$pos2 = stripos($search, $findme);
if ($pos2 !== false) {
$search = str_ireplace ( $findme , '<b>'.$findme.'</b>' , $search );
echo $search;
}
}
?>
here, I am getting array of string in $category->name like Bangladesh, Cricket, CHI, Sport .... Now in my $search string I have a small paragraph for instance, I want to replace any word that matches from the $category->name array. but problem is if it gets multiple replaces then it printing out that many times.
I dont know how to solve it, should be easy but cannot get it right.