3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ["person_id" => 22180, "position" => ["Secretary"], "person_name" => "Person 1"], ["person_id" => 51135, "position" => ["President"], "person_name" => "Person 2"], ["person_id" => 51136, "position" => ["General Secretary", "Committee Member"], "person_name" => "Person 3"], ["person_id" => 44141, "position" => ["Treasurer"], "person_name" => "Person 4"], ["person_id" => 51137, "position" => ["Committee Member"], "person_name" => "Person 5"] ]; $priorities = array_flip([ 'General Secretary', 'President', 'Treasurer', 'Secretary', 'Committee Member', ]); array_multisort( array_map( fn($row) => min( array_map( fn($p) => $priorities[$p], $row['position'] ) ), $array ), $array ); var_export($array);
Output for 8.1.32, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
array ( 0 => array ( 'person_id' => 51136, 'position' => array ( 0 => 'General Secretary', 1 => 'Committee Member', ), 'person_name' => 'Person 3', ), 1 => array ( 'person_id' => 51135, 'position' => array ( 0 => 'President', ), 'person_name' => 'Person 2', ), 2 => array ( 'person_id' => 44141, 'position' => array ( 0 => 'Treasurer', ), 'person_name' => 'Person 4', ), 3 => array ( 'person_id' => 22180, 'position' => array ( 0 => 'Secretary', ), 'person_name' => 'Person 1', ), 4 => array ( 'person_id' => 51137, 'position' => array ( 0 => 'Committee Member', ), 'person_name' => 'Person 5', ), )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
78.06 ms | 408 KiB | 5 Q