3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ "Aulas Gratuitas", "149", "151", "153", "Módulo 0", "964", "989", "967", "978", "Módulo 1", "985", "1079", "1001", "1003", "1005", "Módulo 2", ]; $result = []; foreach ($array as $value) { if (!ctype_digit($value)) { unset($units); $units = []; $result[] = ['title' => $value, 'units' => &$units]; } else { $units[] = $value; } } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'title' => 'Aulas Gratuitas', 'units' => array ( 0 => '149', 1 => '151', 2 => '153', ), ), 1 => array ( 'title' => 'Módulo 0', 'units' => array ( 0 => '964', 1 => '989', 2 => '967', 3 => '978', ), ), 2 => array ( 'title' => 'Módulo 1', 'units' => array ( 0 => '985', 1 => '1079', 2 => '1001', 3 => '1003', 4 => '1005', ), ), 3 => array ( 'title' => 'Módulo 2', 'units' => 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:
29.31 ms | 407 KiB | 5 Q