3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ '.aero', '.airport.aero', '.cargo.aero', '.charter.aero', '.aetna' ]; $result = []; foreach ($array as $value) { if (!preg_match('/(?!^)\..+/', $value, $m)) { $result[$value] = ['tld' => $value, 'gTLD' => []]; } else { $result[$m[0]]['gTLD'][] = $value; } } var_export(array_values($result));
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'tld' => '.aero', 'gTLD' => array ( 0 => '.airport.aero', 1 => '.cargo.aero', 2 => '.charter.aero', ), ), 1 => array ( 'tld' => '.aetna', 'gTLD' => array ( ), ), )

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