3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [['price' => 3800, 'id' => 400015], ['price' => 3700, 'id' => 400015], ['price' => 3300, 'id' => 400018], ['price' => 3000, 'id' => 400018], ['price' => 3100, 'id' => 400020], ['price' => 3400, 'id' => 400020], ]; usort($data, function($a, $b) { return $a['price'] <=> $b['price']; }); $maxPrices = array_column($data, 'price', 'id'); usort($data, function($a, $b) { return $b['price'] <=> $a['price']; }); $minPrices = array_column($data, 'price', 'id'); foreach($minPrices as $id => $minPrice) { echo 'id:', $id, ', Price=', $minPrice, '-', $maxPrices[$id], PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 35
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 35
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/l0oQU
function name:  (null)
number of ops:  37
compiled vars:  !0 = $data, !1 = $maxPrices, !2 = $minPrices, !3 = $minPrice, !4 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
          4        SEND_VAL                                                 ~6
          5        DO_ICALL                                                 
   12     6        INIT_FCALL                                               'array_column'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 'price'
          9        SEND_VAL                                                 'id'
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !1, $8
   14    12        INIT_FCALL                                               'usort'
         13        SEND_REF                                                 !0
         14        DECLARE_LAMBDA_FUNCTION                          ~10     [1]
         15        SEND_VAL                                                 ~10
         16        DO_ICALL                                                 
   15    17        INIT_FCALL                                               'array_column'
         18        SEND_VAR                                                 !0
         19        SEND_VAL                                                 'price'
         20        SEND_VAL                                                 'id'
         21        DO_ICALL                                         $12     
         22        ASSIGN                                                   !2, $12
   17    23      > FE_RESET_R                                       $14     !2, ->35
         24    > > FE_FETCH_R                                       ~15     $14, !3, ->35
         25    >   ASSIGN                                                   !4, ~15
   18    26        ECHO                                                     'id%3A'
         27        ECHO                                                     !4
         28        ECHO                                                     '%2C+Price%3D'
         29        ECHO                                                     !3
         30        ECHO                                                     '-'
         31        FETCH_DIM_R                                      ~17     !1, !4
         32        ECHO                                                     ~17
         33        ECHO                                                     '%0A'
   17    34      > JMP                                                      ->24
         35    >   FE_FREE                                                  $14
   19    36      > 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/l0oQU
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !0, 'price'
          3        FETCH_DIM_R                                      ~3      !1, 'price'
          4        SPACESHIP                                        ~4      ~2, ~3
          5      > RETURN                                                   ~4
          6*     > RETURN                                                   null

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/l0oQU
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !1, 'price'
          3        FETCH_DIM_R                                      ~3      !0, 'price'
          4        SPACESHIP                                        ~4      ~2, ~3
          5      > RETURN                                                   ~4
          6*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.54 ms | 1006 KiB | 15 Q