3v4l.org

run code in 300+ PHP versions simultaneously
<?php $original_values = array( 'Bridge Work' => array( array('Name' => 'NJ Trunpike_Bridge Repair Work', 'Location' => 'New Jersey', 'State' => 'New Jersey'), array('Name' => 'Honoapiilani Highway Bridge Truss', 'Location' => 'Maui', 'State' => 'Hawaii'), array('Name' => 'BlueCross Blueshield of Tennessee (Bridge)', 'Location' => 'Memphis', 'State' => 'Tennessee'), array('Name' => 'Henderson Center Connector Bridge', 'Location' => 'Coquitlam', 'State' => 'British Columbia'), ), 'Educational' => array( array('Name' => 'RTI TASS Complex Admin Bldg', 'Location' => 'Bluffdale', 'State' => 'Utah'), array('Name' => 'Auburn High School', 'Location' => 'Auburn', 'State' => 'Washington'), array('Name' => 'Reed College', 'Location' => 'Portland', 'State' => 'Oregon'), array('Name' => 'Shorewood High School', 'Location' => 'Shoreline', 'State' => 'Washington'), ),); function my_sort($my_array, $my_key) { $sorted_values = array(); foreach($my_array as $key => $value) { $columns = null; foreach ($value as $index => $element) { $columns[] = $element[$my_key]; } $temp = $value; array_multisort($columns, SORT_ASC, $temp); $sorted_values[$key] = $temp; } return $sorted_values; } $result = my_sort($original_values, 'Name'); echo '<pre>'; print_r($result); echo '</pre>';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ok7IA
function name:  (null)
number of ops:  12
compiled vars:  !0 = $original_values, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   21     1        INIT_FCALL                                               'my_sort'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'Name'
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   23     6        ECHO                                                     '%3Cpre%3E'
          7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
         10        ECHO                                                     '%3C%2Fpre%3E'
         11      > RETURN                                                   1

Function my_sort:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 24
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 14
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/ok7IA
function name:  my_sort
number of ops:  27
compiled vars:  !0 = $my_array, !1 = $my_key, !2 = $sorted_values, !3 = $value, !4 = $key, !5 = $columns, !6 = $element, !7 = $index, !8 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        ASSIGN                                                   !2, <array>
    7     3      > FE_RESET_R                                       $10     !0, ->24
          4    > > FE_FETCH_R                                       ~11     $10, !3, ->24
          5    >   ASSIGN                                                   !4, ~11
    9     6        ASSIGN                                                   !5, null
   10     7      > FE_RESET_R                                       $14     !3, ->14
          8    > > FE_FETCH_R                                       ~15     $14, !6, ->14
          9    >   ASSIGN                                                   !7, ~15
   12    10        FETCH_DIM_R                                      ~18     !6, !1
         11        ASSIGN_DIM                                               !5
         12        OP_DATA                                                  ~18
   10    13      > JMP                                                      ->8
         14    >   FE_FREE                                                  $14
   14    15        ASSIGN                                                   !8, !3
   15    16        INIT_FCALL                                               'array_multisort'
         17        SEND_REF                                                 !5
         18        SEND_VAL                                                 4
         19        SEND_REF                                                 !8
         20        DO_ICALL                                                 
   16    21        ASSIGN_DIM                                               !2, !4
         22        OP_DATA                                                  !8
    7    23      > JMP                                                      ->4
         24    >   FE_FREE                                                  $10
   18    25      > RETURN                                                   !2
   19    26*     > RETURN                                                   null

End of function my_sort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.52 ms | 1403 KiB | 18 Q