3v4l.org

run code in 300+ PHP versions simultaneously
<?php $attendance = array( array( "student_id" => "1", "date" => "2016-04-24" ) ); $students = array( array( "student_id" => "1", "Reason" => "", "date" => "2016-04-24" ), array( "student_id" => "6", "Reason" => "1", "date" => "2016-04-24" ) ); $atts = array(); foreach($attendance as $att) { $atts[] = $att->student_id; } foreach($students as &$student) { if(in_array($student['student_id'], $atts)) { $student['Reason']='1'; } else { $student['Reason']='0'; } } echo '<pre>',print_r($students,1),'</pre>';

preferences:
49.59 ms | 402 KiB | 5 Q