Create Search and Get in The Middle String

PHP - 2019-05-15 02:03:54

when I made ??a search on the web, I make it with all the search methods that have character string exactly as keywords, but I was wondering if the amount of string to string ribuaan while I'm looking for is on the order of the last string or middle, for that I make the algorithm the keywords that bring up search results in the search string

 


$kata="i like all source of pasarkode, it make me coolest of the other portal";
$kunci="pasarkode";
$getguri=6;
$arep=10
$getarep=$getguri+$arep;
$ganti="".$kunci."";

$isi=substr($kata,strpos($kata,$kunci)-$getguri,$getarep);
$isi=preg_replace("/".$kunci."/",$ganti,$isi);

echo $isi;

?>