I'm trying to search for the occurrence of certain words in a string and match them with a short list in an array. I'll explain my question by means of an example.
$arrTitle = explode(" ", "Suburban Apartments");
foreach( $arrTitle as $key => $value){
echo "Name: $key, Age: $value <br />";
$words = array("hotel", "apart", "hostel");
if (in_array($value, $words)) {
echo "Exists";
}
}
I wish to compare a part of the string, in the above example 'Apartments' against the $words array for the occurrence of the string 'Apart'ments. I hope this makes sense. Is this possible at all?
Thanks