3v4l.org

run code in 500+ PHP versions simultaneously
<?php $amsterdam = [ 65 => [ 'table' => 'Object', 'something' => false, 'data' => [ 'foo' => 'boo', 'price' => 100 ] ], 173 => [ 'table' => 'Object', 'something' => false, 'data' => [ 'foo' => 'hoo', 'price' => 2500 ] ], ]; $prague = [ 132 => [ 'table' => 'Object', 'something' => false, 'data' => [ 'foo' => 'boo', 'price' => 2100 ] ], 956 => [ 'table' => 'Object', 'something' => false, 'data' => [ 'foo' => 'hoo', 'price' => 2500 ] ], ]; $lisboa = [ 175 => [ 'table' => 'Object', 'something' => false, 'data' => [ 'foo' => 'boo', 'price' => 6500 ] ], 64 => [ 'table' => 'Object', 'something' => false, 'data' => [ 'foo' => 'hoo', 'price' => 20 ] ], ]; $cities = [ 'amsterdam' => $amsterdam, 'prague' => $prague, 'lisboa' => $lisboa ]; $map_prices = function($n) { $reduce_smallest_price = function($carry, $item) { return $item['data']['price'] < $carry ? $item['data']['price'] : $carry; }; return array_reduce($n, $reduce_smallest_price, INF); }; $cities_price = array_map($map_prices, $cities); asort($cities_price); uksort($cities, function($a, $b) { global $cities_price; return strnatcmp($cities_price[$a], $cities_price[$b]); }); print_r($cities_price); print_r($cities);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8B9VN
function name:  (null)
number of ops:  29
compiled vars:  !0 = $amsterdam, !1 = $prague, !2 = $lisboa, !3 = $cities, !4 = $map_prices, !5 = $cities_price
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   22     1        ASSIGN                                                       !1, <array>
   41     2        ASSIGN                                                       !2, <array>
   62     3        INIT_ARRAY                                           ~9      !0, 'amsterdam'
   63     4        ADD_ARRAY_ELEMENT                                    ~9      !1, 'prague'
   64     5        ADD_ARRAY_ELEMENT                                    ~9      !2, 'lisboa'
   61     6        ASSIGN                                                       !3, ~9
   70     7        DECLARE_LAMBDA_FUNCTION                              ~11     [0]
          8        ASSIGN                                                       !4, ~11
   80     9        INIT_FCALL                                                   'array_map'
         10        SEND_VAR                                                     !4
         11        SEND_VAR                                                     !3
         12        DO_ICALL                                             $13     
         13        ASSIGN                                                       !5, $13
   82    14        INIT_FCALL                                                   'asort'
         15        SEND_REF                                                     !5
         16        DO_ICALL                                                     
   83    17        INIT_FCALL                                                   'uksort'
         18        SEND_REF                                                     !3
         19        DECLARE_LAMBDA_FUNCTION                              ~16     [1]
   87    20        SEND_VAL                                                     ~16
   83    21        DO_ICALL                                                     
   89    22        INIT_FCALL                                                   'print_r'
         23        SEND_VAR                                                     !5
         24        DO_ICALL                                                     
   90    25        INIT_FCALL                                                   'print_r'
         26        SEND_VAR                                                     !3
         27        DO_ICALL                                                     
         28      > 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/8B9VN
function name:  {closure:/in/8B9VN:70}
number of ops:  10
compiled vars:  !0 = $n, !1 = $reduce_smallest_price
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   70     0  E >   RECV                                                 !0      
   71     1        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
          2        ASSIGN                                                       !1, ~2
   76     3        INIT_FCALL                                                   'array_reduce'
          4        SEND_VAR                                                     !0
          5        SEND_VAR                                                     !1
          6        SEND_VAL                                                     INF
          7        DO_ICALL                                             $4      
          8      > RETURN                                                       $4
   78     9*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8B9VN
function name:  {closure:{closure:/in/8B9VN:70}:71}
number of ops:  13
compiled vars:  !0 = $carry, !1 = $item
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   71     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   72     2        FETCH_DIM_R                                          ~2      !1, 'data'
          3        FETCH_DIM_R                                          ~3      ~2, 'price'
          4        IS_SMALLER                                                   ~3, !0
          5      > JMPZ                                                         ~4, ->10
   73     6    >   FETCH_DIM_R                                          ~5      !1, 'data'
          7        FETCH_DIM_R                                          ~6      ~5, 'price'
          8        QM_ASSIGN                                            ~7      ~6
          9      > JMP                                                          ->11
   74    10    >   QM_ASSIGN                                            ~7      !0
         11    > > RETURN                                                       ~7
   75    12*     > RETURN                                                       null

End of Dynamic Function 0

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8B9VN
function name:  {closure:/in/8B9VN:83}
number of ops:  11
compiled vars:  !0 = $a, !1 = $b, !2 = $cities_price
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   83     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   84     2        BIND_GLOBAL                                                  !2, 'cities_price'
   85     3        INIT_FCALL                                                   'strnatcmp'
          4        FETCH_DIM_R                                          ~3      !2, !0
          5        SEND_VAL                                                     ~3
          6        FETCH_DIM_R                                          ~4      !2, !1
          7        SEND_VAL                                                     ~4
          8        DO_ICALL                                             $5      
          9      > RETURN                                                       $5
   87    10*     > RETURN                                                       null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
225.79 ms | 2719 KiB | 19 Q