3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['name' => 'Dr. Hugo Lopez', 'duty' => 'Anesthesiologist', 'link' => ''], ['name' => 'Dr. Dario Garin', 'duty' => 'Orthopedic Specialist', 'link' => 'dr-dario-garin.php'], ['name' => 'Dr. Maclovio Yañez', 'duty' => 'Plastic Surgeon', 'link' => ''], ['name' => 'Melissa Bracker', 'duty' => 'Patient Liaison', 'link' => ''], ['name' => 'Dr. Diego Guzman', 'duty' => 'Cardiologist', 'link' => ''], ['name' => 'Ivan Arafat', 'duty' => 'Accountant', 'link' => ''], ['name' => 'Jorge Fernandez', 'duty' => 'Hospital Administrator', 'link' => ''], ]; $lookup = array_flip(['Hospital Administrator', 'Plastic Surgeon', 'Orthopedic Specialist']); $fallback = count($lookup); usort($array, function ($a, $b) use ($lookup, $fallback) { $aName = array_reverse(preg_match('~^((?:[a-z]+\.)?) ?(\S+) (.+)~i', $a['name'], $out) ? $out : ['', '', '']); $bName = array_reverse(preg_match('~^((?:[a-z]+\.)?) ?(\S+) (.+)~i', $b['name'], $out) ? $out : ['', '', '']); return [$lookup[$a['duty']] ?? $fallback, ...$aName] <=> [$lookup[$b['duty']] ?? $fallback, ...$bName]; }); var_export($array);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'name' => 'Jorge Fernandez', 'duty' => 'Hospital Administrator', 'link' => '', ), 1 => array ( 'name' => 'Dr. Maclovio Yañez', 'duty' => 'Plastic Surgeon', 'link' => '', ), 2 => array ( 'name' => 'Dr. Dario Garin', 'duty' => 'Orthopedic Specialist', 'link' => 'dr-dario-garin.php', ), 3 => array ( 'name' => 'Ivan Arafat', 'duty' => 'Accountant', 'link' => '', ), 4 => array ( 'name' => 'Melissa Bracker', 'duty' => 'Patient Liaison', 'link' => '', ), 5 => array ( 'name' => 'Dr. Diego Guzman', 'duty' => 'Cardiologist', 'link' => '', ), 6 => array ( 'name' => 'Dr. Hugo Lopez', 'duty' => 'Anesthesiologist', 'link' => '', ), )

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:
126.57 ms | 407 KiB | 5 Q