$meal_type= "Free Breakfast|Free Wireless";
if ($meal_type != '' && $meal_type !='None') {
$meal = explode('|', $meal_type);
$meal = array_search('Breakfast',$meal);
$meal = $meal_type;
} else {
$meal= 'No Breakfast';
}
echo $meal;
This is my code. here i want to search Breakfast
in the array and return searched value, if not found return No Breakfast
.
Here i was explode string to array with | symbol and returned array search Breakfast if exist return funded array value else echo No Breakfast value.