3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = [ ['name' => 'Beavis'], ['name' => 'Butthead'], ['name' => 'Cornholio', 'caffine_powered' => true], ]; $sorter = function($a, $b){ if( key_exists('caffine_powered', $a) && key_exists('caffine_powered', $b) ) { // both exist return $a['name'] <=> $b['name']; } else if( ! (key_exists('caffine_powered', $a) || key_exists('caffine_powered', $b)) ) { // neither exist return $a['name'] <=> $b['name']; } else if( key_exists('caffine_powered', $a) ) { // just a return -1; } else { // just b return 1; } }; usort($items, $sorter); var_dump($items);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6ORYb
function name:  (null)
number of ops:  11
compiled vars:  !0 = $items, !1 = $sorter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F6ORYb%3A8%240'
          2        ASSIGN                                                   !1, ~3
   24     3        INIT_FCALL                                               'usort'
          4        SEND_REF                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                                 
   25     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F6ORYb%3A8%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 47) Position 1 = 23, Position 2 = 28
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
Branch analysis from position: 12
filename:       /in/6ORYb
function name:  {closure}
number of ops:  44
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        INIT_FCALL                                               'key_exists'
          3        SEND_VAL                                                 'caffine_powered'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6      > JMPZ_EX                                          ~3      $2, ->12
          7    >   INIT_FCALL                                               'key_exists'
          8        SEND_VAL                                                 'caffine_powered'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $4      
         11        BOOL                                             ~3      $4
         12    > > JMPZ                                                     ~3, ->18
   11    13    >   FETCH_DIM_R                                      ~5      !0, 'name'
         14        FETCH_DIM_R                                      ~6      !1, 'name'
         15        SPACESHIP                                        ~7      ~5, ~6
         16      > RETURN                                                   ~7
         17*       JMP                                                      ->43
   12    18    >   INIT_FCALL                                               'key_exists'
         19        SEND_VAL                                                 'caffine_powered'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $8      
         22      > JMPNZ_EX                                         ~9      $8, ->28
         23    >   INIT_FCALL                                               'key_exists'
         24        SEND_VAL                                                 'caffine_powered'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $10     
         27        BOOL                                             ~9      $10
         28    >   BOOL_NOT                                         ~11     ~9
         29      > JMPZ                                                     ~11, ->35
   14    30    >   FETCH_DIM_R                                      ~12     !0, 'name'
         31        FETCH_DIM_R                                      ~13     !1, 'name'
         32        SPACESHIP                                        ~14     ~12, ~13
         33      > RETURN                                                   ~14
         34*       JMP                                                      ->43
   15    35    >   INIT_FCALL                                               'key_exists'
         36        SEND_VAL                                                 'caffine_powered'
         37        SEND_VAR                                                 !0
         38        DO_ICALL                                         $15     
         39      > JMPZ                                                     $15, ->42
   17    40    > > RETURN                                                   -1
         41*       JMP                                                      ->43
   20    42    > > RETURN                                                   1
   23    43*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F6ORYb%3A8%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
203.42 ms | 1400 KiB | 19 Q