3v4l.org

run code in 500+ PHP versions simultaneously
<?php $amsterdam = [ 65 => [ 'something' => false, 'data' => [ 'foo' => 'boo', 'price' => 100 ] ], 173 => [ 'something' => false, 'data' => [ 'foo' => 'hoo', 'price' => 2500 ] ], ]; $prague = [ 132 => [ 'something' => false, 'data' => [ 'foo' => 'boo', 'price' => 2100 ] ], 956 => [ 'something' => false, 'data' => [ 'foo' => 'hoo', 'price' => 2500 ] ], ]; $lisboa = [ 175 => [ 'something' => false, 'data' => [ 'foo' => 'boo', 'price' => 6500 ] ], 64 => [ 'something' => false, 'data' => [ 'foo' => 'hoo', 'price' => 20 ] ], ]; $cities = [ 'amsterdam' => $amsterdam, 'prague' => $prague, 'lisboa' => $lisboa ]; function getMinimumPrice($cityArray) { return array_reduce($cityArray, function($carry, $item) { return $carry === 0 ? $item['data']['price'] : min($carry, $item['data']['price']); }, 0); } uasort($cities, function($city1, $city2) { $priceCity1 = getMinimumPrice($city1); $priceCity2 = getMinimumPrice($city2); return $priceCity1 <=> $priceCity2; }); var_dump($cities);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fYOfd
function name:  (null)
number of ops:  16
compiled vars:  !0 = $amsterdam, !1 = $prague, !2 = $lisboa, !3 = $cities
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                       !0, <array>
   22     1        ASSIGN                                                       !1, <array>
   39     2        ASSIGN                                                       !2, <array>
   57     3        INIT_ARRAY                                           ~7      !0, 'amsterdam'
   58     4        ADD_ARRAY_ELEMENT                                    ~7      !1, 'prague'
   59     5        ADD_ARRAY_ELEMENT                                    ~7      !2, 'lisboa'
   56     6        ASSIGN                                                       !3, ~7
   68     7        INIT_FCALL                                                   'uasort'
          8        SEND_REF                                                     !3
          9        DECLARE_LAMBDA_FUNCTION                              ~9      [0]
   73    10        SEND_VAL                                                     ~9
   68    11        DO_ICALL                                                     
   74    12        INIT_FCALL                                                   'var_dump'
         13        SEND_VAR                                                     !3
         14        DO_ICALL                                                     
         15      > 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/fYOfd
function name:  {closure:/in/fYOfd:68}
number of ops:  13
compiled vars:  !0 = $city1, !1 = $city2, !2 = $priceCity1, !3 = $priceCity2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   68     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   69     2        INIT_FCALL                                                   'getminimumprice'
          3        SEND_VAR                                                     !0
          4        DO_FCALL                                          0  $4      
          5        ASSIGN                                                       !2, $4
   70     6        INIT_FCALL                                                   'getminimumprice'
          7        SEND_VAR                                                     !1
          8        DO_FCALL                                          0  $6      
          9        ASSIGN                                                       !3, $6
   72    10        SPACESHIP                                            ~8      !2, !3
         11      > RETURN                                                       ~8
   73    12*     > RETURN                                                       null

End of Dynamic Function 0

Function getminimumprice:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fYOfd
function name:  getMinimumPrice
number of ops:  9
compiled vars:  !0 = $cityArray
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   62     0  E >   RECV                                                 !0      
   63     1        INIT_FCALL                                                   'array_reduce'
          2        SEND_VAR                                                     !0
          3        DECLARE_LAMBDA_FUNCTION                              ~1      [0]
   65     4        SEND_VAL                                                     ~1
          5        SEND_VAL                                                     0
   63     6        DO_ICALL                                             $2      
   65     7      > RETURN                                                       $2
   66     8*     > RETURN                                                       null


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

End of Dynamic Function 0

End of function getminimumprice

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.42 ms | 2620 KiB | 18 Q