3v4l.org

run code in 300+ PHP versions simultaneously
<?php $students = Array( Array( 'userId' => 'user1', 'name' => 'Suman Mandal', 'age' => 20, ), Array( 'userId' => 'user2', 'name' => 'Amit Halder', 'age' => 30, ), Array( 'userId' => 'user3', 'name' => 'Asif Rahman', 'age' => 25, ), Array( 'userId' => 'user4', 'name' => 'Gopal Ghosh', 'age' => 21, ) ); $marks = Array( Array( 'userId' => 'user1', 'marks'=>80, ), Array( 'userId' => 'user3', 'marks'=>90, ) ); $marks_sheet = []; foreach ($marks as $mark) { foreach ($students as $student) { if ($student['userId'] === $mark['userId']) { $mark_sheet = $student; foreach ($mark as $key => $value) { $mark_sheet[$key] = $value; } $marks_sheet[] = $mark_sheet; } } } print_r($marks_sheet);
Output for git.master_jit, git.master, rfc.property-hooks
Array ( [0] => Array ( [userId] => user1 [name] => Suman Mandal [age] => 20 [marks] => 80 ) [1] => Array ( [userId] => user3 [name] => Asif Rahman [age] => 25 [marks] => 90 ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
16.73 ms | 406 KiB | 5 Q