3v4l.org

run code in 300+ PHP versions simultaneously
<?php $belongGroup = [ 2, 1 ]; $groups = [ 1 => ['parent_group_id' => 0, 'group_id' => 1], 2 => ['parent_group_id' => 1, 'group_id' => 2], 3 => ['parent_group_id' => 0, 'group_id' => 3], 4 => ['parent_group_id' => 0, 'group_id' => 4], ]; $result = []; foreach($belongGroup as $g) { $l = $groups[$g]; var_dump($l); while(true) { echo $l['parent_group_id'] == 0; if ($l['parent_group_id'] == 0) { break; } $parentId = $l['parent_group_id']; $l = $groups[$parentId]; unset($groups[$parentId]); } $result[] = intval($l['group_id']); } echo implode(", ", $result);
Output for git.master, git.master_jit
array(2) { ["parent_group_id"]=> int(1) ["group_id"]=> int(2) } 1 Warning: Undefined array key 1 in /in/3nUVo on line 16 NULL Warning: Trying to access array offset on value of type null in /in/3nUVo on line 19 1 Warning: Trying to access array offset on value of type null in /in/3nUVo on line 20 Warning: Trying to access array offset on value of type null in /in/3nUVo on line 27 1, 0
Output for rfc.property-hooks
array(2) { ["parent_group_id"]=> int(1) ["group_id"]=> int(2) } 1 Warning: Undefined array key 1 in /in/3nUVo on line 16 NULL Warning: Trying to access array offset on null in /in/3nUVo on line 19 1 Warning: Trying to access array offset on null in /in/3nUVo on line 20 Warning: Trying to access array offset on null in /in/3nUVo on line 27 1, 0

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:
64.4 ms | 401 KiB | 8 Q