3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( "FL_1" => array( "MIC_1" => array( "SP_4" => 7 ), "MIC_13" => array( "SP_16" => 4 ), "MIC_6" => array( "SP_74" => 4 ) ), "FL_2" => array( "MIC_1" => array( "SP_5" => 4 ), "MIC_13" => array( "SP_17" => 4 ), "MIC_6" => array( "SP_75" => 4 ) ), "FL_3" => array( "MIC_1" => array( "SP_5" => 89 ), "MIC_13" => array( "SP_18" => 1 ), "MIC_6" => array( "SP_78" => 21 ) ) ); // find the minimum SP_X value and its key $min_sp = PHP_INT_MAX; $min_key = ''; array_walk_recursive($array, function ($v, $k) use (&$min_sp, &$min_key) { if ($v < $min_sp) { $min_sp = $v; $min_key = $k; } }); echo "$min_key => $min_sp\n"; // find the MIC_X key corresponding to the min SP_X value $mic_key = ''; foreach ($array as $fl) { foreach ($fl as $mic => $sp) { if (isset($sp[$min_key]) && $sp[$min_key] == $min_sp) { $mic_key = $mic; break 2; } } } echo "$mic_key\n"; // filter the array to get all the MIC_X values $out = array_map(function ($fl) use ($mic_key) { return array_filter($fl, function ($mic) use ($mic_key) { return $mic == $mic_key; }, ARRAY_FILTER_USE_KEY); }, $array); print_r($out);
Output for git.master, git.master_jit, rfc.property-hooks
SP_18 => 1 MIC_13 Array ( [FL_1] => Array ( [MIC_13] => Array ( [SP_16] => 4 ) ) [FL_2] => Array ( [MIC_13] => Array ( [SP_17] => 4 ) ) [FL_3] => Array ( [MIC_13] => Array ( [SP_18] => 1 ) ) )

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:
29.64 ms | 406 KiB | 5 Q