3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 0 => ['Peter' => 4], 1 => ['Piper' => 4], 2 => ['picked' => 4], 3 => ['peck' => 4], 4 => ['pickled' => 4], ]; $temp = array_map(function($a){ return key($a); }, $arr); natcasesort($temp); $result = []; foreach($temp as $v){ foreach($arr as $v1){ if($v == key($v1)){ $result[] = $v1; break; } } } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 26
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 26
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 24
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 24
Branch analysis from position: 24
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/8I2sL
function name:  (null)
number of ops:  31
compiled vars:  !0 = $arr, !1 = $temp, !2 = $result, !3 = $v, !4 = $v1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        INIT_FCALL                                               'array_map'
          2        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
   12     3        SEND_VAL                                                 ~6
          4        SEND_VAR                                                 !0
   10     5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !1, $7
   13     7        INIT_FCALL                                               'natcasesort'
          8        SEND_REF                                                 !1
          9        DO_ICALL                                                 
   14    10        ASSIGN                                                   !2, <array>
   15    11      > FE_RESET_R                                       $11     !1, ->26
         12    > > FE_FETCH_R                                               $11, !3, ->26
   16    13    > > FE_RESET_R                                       $12     !0, ->24
         14    > > FE_FETCH_R                                               $12, !4, ->24
   17    15    >   INIT_FCALL                                               'key'
         16        SEND_VAR                                                 !4
         17        DO_ICALL                                         $13     
         18        IS_EQUAL                                                 !3, $13
         19      > JMPZ                                                     ~14, ->23
   18    20    >   ASSIGN_DIM                                               !2
         21        OP_DATA                                                  !4
   19    22      > JMP                                                      ->24
   16    23    > > JMP                                                      ->14
         24    >   FE_FREE                                                  $12
   15    25      > JMP                                                      ->12
         26    >   FE_FREE                                                  $11
   23    27        INIT_FCALL                                               'print_r'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                                 
         30      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8I2sL
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'key'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   12     5*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.55 ms | 1006 KiB | 17 Q