3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array ( array ( 'result_title' => 'Agathoklis Georgiou', 'result_subtext' => 'Active Employee' ), array ( 'result_title' => 'Frixos Georgiou', 'result_subtext' => 'Active Employee' ), array ( 'result_title' => 'George Ellinas', 'result_subtext' => 'Active Employee' ), array ( 'result_title' => 'Fred Ellinas', 'result_subtext' => 'Active Employee' ), array ( 'result_title' => 'Georgi Georgiev', 'result_subtext' => 'Active Employee' ), array ( 'result_title' => 'Charalambos Georgiou', 'result_subtext' => 'Former Employee' ), array ( 'result_title' => 'Georgia Kantouna', 'result_subtext' => 'Former Employee' ) ); $term = 'geo'; usort($data, function ($a, $b) use ($term) { // find the term in first entry $t1 = preg_match("/^.*?\b($term\w+).*\$/i", $a['result_title'], $matches) ? $matches[1] : ''; // find the term in second entry $t2 = preg_match("/^.*?\b($term\w+).*\$/i", $b['result_title'], $matches) ? $matches[1] : ''; // check if the terms were found if ($t1 == '' && $t2 != '') return 1; if ($t1 != '' && $t2 == '') return -1; // found in both - if not the same, just sort on the keyword if ($t1 != $t2) return strcmp($t1, $t2); // found the same keyword, sort on the whole title return strcmp($a['result_title'], $b['result_title']); }); print_r($data);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [result_title] => George Ellinas [result_subtext] => Active Employee ) [1] => Array ( [result_title] => Georgi Georgiev [result_subtext] => Active Employee ) [2] => Array ( [result_title] => Georgia Kantouna [result_subtext] => Former Employee ) [3] => Array ( [result_title] => Agathoklis Georgiou [result_subtext] => Active Employee ) [4] => Array ( [result_title] => Charalambos Georgiou [result_subtext] => Former Employee ) [5] => Array ( [result_title] => Frixos Georgiou [result_subtext] => Active Employee ) [6] => Array ( [result_title] => Fred Ellinas [result_subtext] => Active Employee ) )

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:
19.77 ms | 403 KiB | 8 Q