I have a function to loop through multidimensional array :
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;
}
Then, I use it like this :
$hoursoff = array( array("10:00" => "2016-10-07", "11:00" => "2016-10-07", "12:00" => "2016-10-07"), array("10:00" => "2016-10-08", "11:00" => "2016-10-08") );
if( in_multiarray("$date", $hoursoff, "$hour") ) { /* do it */ } else { /* don't do it */ }
/* $date and $hour come from database request */
this works fine. But when I check my error_reporting(E_ALL); it throws
Notice: Undefined index ...
I know it's no big deal, and does not affect results, but in order to learn from this : * which part of the script is involved in this error ? * how do I avoid having this (or what am I doing wrong) ? thanks