3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myArray = array( 'Europe' => 'World', 'Asia' => 'World', 'Africa' => 'World', 'France' => 'Europe', 'Poland' => 'Europe', 'Germany' => 'Europe', 'Paris' => 'France', 'Lille' => 'France', 'Warsaw' => 'Poland', 'Szczecin' => 'Poland', 'Berlin' => 'Germany', 'Gumience' => 'Szczecin' ); foreach($myArray as $key => $val) { $element = build($key, $myArray); if ($element) { $result[$element][$key] = $value; } else { $result[][$value] = array(); } } function build($needle, $haystack) { foreach($haystack as $key => $value) { if ($needle === $key OR (is_array($value) && build($needle, $value) !== false)) { return $value; } } return false; } function print_r2($val){ echo '<pre>'; print_r($val); echo '</pre>'; } print_r2($myArray); echo ('<br /><br />'); print_r2($result); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $value in /in/OGoXa on line 27 Warning: Undefined variable $value in /in/OGoXa on line 27 Warning: Undefined variable $value in /in/OGoXa on line 27 Warning: Undefined variable $value in /in/OGoXa on line 27 Warning: Undefined variable $value in /in/OGoXa on line 27 Warning: Undefined variable $value in /in/OGoXa on line 27 Warning: Undefined variable $value in /in/OGoXa on line 27 Warning: Undefined variable $value in /in/OGoXa on line 27 Warning: Undefined variable $value in /in/OGoXa on line 27 Warning: Undefined variable $value in /in/OGoXa on line 27 Warning: Undefined variable $value in /in/OGoXa on line 27 Warning: Undefined variable $value in /in/OGoXa on line 27 <pre>Array ( [Europe] => World [Asia] => World [Africa] => World [France] => Europe [Poland] => Europe [Germany] => Europe [Paris] => France [Lille] => France [Warsaw] => Poland [Szczecin] => Poland [Berlin] => Germany [Gumience] => Szczecin ) </pre><br /><br /><pre>Array ( [World] => Array ( [Europe] => [Asia] => [Africa] => ) [Europe] => Array ( [France] => [Poland] => [Germany] => ) [France] => Array ( [Paris] => [Lille] => ) [Poland] => Array ( [Warsaw] => [Szczecin] => ) [Germany] => Array ( [Berlin] => ) [Szczecin] => Array ( [Gumience] => ) ) </pre>

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:
35.14 ms | 411 KiB | 5 Q