I am trying to match a word with list of tag names in an array using preg_grep
$tagOptArray = array("Corporate", "Exporters", "Buyers", "News", "Apparel","Aquarium Fish", "Boat and Ship Building");
$subBlockTag = "Boat";
$tag = preg_grep('/' . $subBlockTag . '[.]*/i', $tagOptArray);
var_dump($tag);
this outputs the following result.
array(1) { [6]=> string(22) "Boat and Ship Building" }
But when $subBlockTag = "Boat Building";
this returns an empty array which is not expected since it should match with "Boat and Ship Building" in the tags array.
EDIT
following are the possible tags that can be assigned for $subBlockTag
$subBlockTag = "Boat Building";
$subBlockTag = "Ornamental Fish";
$subBlockTag = "Fish";
$subBlockTag = "Fruits and Vegetables";
$subBlockTag = "Diamond and Jewellery";