3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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>';
based on BBskE
Output for 5.5.0 - 7.3.1
<pre>Array ( [0] => Array ( [student_id] => 1 [Reason] => 1 [date] => 2016-04-24 ) [1] => Array ( [student_id] => 6 [Reason] => 0 [date] => 2016-04-24 ) ) </pre>