How to find exact match of word in a string
This is how you find an exact word in some text string. The "\b" is for finding the words boundary and the "i" is to let the search be case insensitive.
<?php
$matches = array();
$text = "Play poker"; //Some text
$keyword = "Poker";
preg_match("/\b".$keyword."\b/i", $text, $matches, PREG_OFFSET_CAPTURE);
foreach ($matches as $key => $value) {
echo "<br>$key => $value";
}
?>
Array
(
[0] => Array
(
[0] => poker
[1] => 5
)
)Knowledge keywords:
