> So, if it is not in the array I wanted to give a message out. This
> does not work for some reason, did I missunderstand the in_array
> function? Any idea to achieve it otherwise?
yes. in_array should be used with a scalar array. you have got a multi-
dimensional array (matrix in your case).
tr
You could try the isset function. isset($this->data['Ingredient']
[$value['In']['ingredientname']]). But if $this->data['Ingredient']
[$value['In']['ingredientname']] is null, it will also return false.
isset checks if variable exists and is not null.
--~--~-~--~~~---~-
Did you try to cycle it with a foreach and search within? Never used the
in_array function. I'll take a look at it.
foreach($this->data['Ingredient'] as $ingredient):
if($ingredient == $ingredient_chosen) {
echo "found!";
}
else
{
echo "not found!";
}
endfore
Hi Guys,
I am trying to find out if a Value in the $this->data Array excists.
Here the structure of the Array:
Array
(
[Recipe] => Array
(
[recipe_name] =>
)
[Ingredient] => Array
(
[1] => Array
(
[ingredientnam