php - Match two items from one entry in an array -
i building array in 'for' loop using following:
$output[] = array('title' => $title, 'start' => $startclean, 'end' => $endclean, 'url' => $url); i need put statement around if title , start date in array, skips above line. happy looking 1 element in array - not sure two...
thanks :)
this should work you:
just use array_reduce() , check if have element same title value , same start value, (where $titlecheck , $startcheck values current iteration):
if(array_reduce($output, function($keep, $v)use($titlecheck, $startcheck){ if($v["title"] == $titlecheck && $v["start"] == $startcheck) $keep = true; return $keep; }, false)) { $output[] = array('title' => $title, 'start' => $startclean, 'end' => $endclean, 'url' => $url); }
Comments
Post a Comment