I have the following array:
Array
(
[0] => Array
(
[6] => 2015-02-27 19:00
)
[1] => Array
(
[6] => 2015-02-27 20:00
)
[2] => Array
(
[6] => 2015-02-27 21:00
)
)
The "6" is a category and I want to check if the category exists with the according date.
I have
$category = 7;
$datetocheck = "2015-02-27 20:00"
The function should return false. If I have
$category = 6;
$datetocheck = "2015-02-27 20:00"
The function should return true.
This https://stackoverflow.com/a/12456356/1092632 looks like what I want to do, but I can't get it to work. Maybe it's not a fitting function.
Any hint/help highly appreciated.
//EDIT I used this function (from above Post)
function in_multiarray($elem, $array,$field)
{
$top = sizeof($array) - 1;
$bottom = 0;
while($bottom <= $top)
{
if($array[$bottom][$field] == $elem)
return true;
else
if(is_array($array[$bottom][$field]))
if(in_multiarray($elem, ($array[$bottom][$field])))
return true;
$bottom++;
}
return false;
}
But when I use it
in_multiarray("2015-02-27 20:00",$myArray,6)
I get undefined index errors. I tried "in_array()" but this gives me true for 6 AND 7.