I'm trying to understand how I can match an array against a line of text, if the text inside the array is found, then I'd like to return that value.
I've tried the following but nothing seems to get returned.
$catArray = array(
'0' => 'breakfast',
'1' => 'lunch',
'2' => 'dinner',
);
$text = 'It is your breakfast';
foreach($catArray as $cat){
if(strpos($cat, $text) !== false){
return $cat;
}
}
By this logic, breakfast
should return.