3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ "2022-10-30" => ['▶'], "2022-10-31" => ['▶'], "2022-11-07" => ['▶'], "2022-11-09" => ['▶'] ]; $result = []; foreach ($array as $key => $value) { $ym = substr($key, 0, 7); if (!isset($lookup[$ym]) || $lookup[$ym] < $key) { $result[$key] = $value; if (isset($lookup[$ym])) { unset($result[$lookup[$ym]]); } $lookup[$ym] = $key; } } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( '2022-10-31' => array ( 0 => '▶', ), '2022-11-09' => array ( 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:
57.55 ms | 401 KiB | 8 Q