3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['id' => 1, 'sort_code' => 4], ['id' => 2, 'sort_code' => 2], ['id' => 3], ['id' => 4, 'sort_code' => 8], ['id' => 5], ['id' => 6, 'sort_code' => 6] ]; uasort($array, function($a, $b) { echo "\n" . json_encode($a) . " -vs- " . json_encode($b) . " eval: "; echo $eval = (int)(isset($a['sort_code'], $b['sort_code']) && $a['sort_code'] > $b['sort_code']); return $eval; }); echo "\n---\n"; var_export($array); echo "\n======\n"; uasort($array, function($a, $b) { echo "\n" . json_encode($a) . " -vs- " . json_encode($b) . " eval: "; echo $eval = ($a['sort_code'] ?? 0) <=> ($b['sort_code'] ?? 0); return $eval; }); echo "\n---\n"; var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vLG09
function name:  (null)
number of ops:  21
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   13     1        INIT_FCALL                                               'uasort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   17     4        SEND_VAL                                                 ~2
   13     5        DO_ICALL                                                 
   18     6        ECHO                                                     '%0A---%0A'
   19     7        INIT_FCALL                                               'var_export'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
   21    10        ECHO                                                     '%0A%3D%3D%3D%3D%3D%3D%0A'
   23    11        INIT_FCALL                                               'uasort'
         12        SEND_REF                                                 !0
         13        DECLARE_LAMBDA_FUNCTION                          ~5      [1]
   27    14        SEND_VAL                                                 ~5
   23    15        DO_ICALL                                                 
   28    16        ECHO                                                     '%0A---%0A'
   29    17        INIT_FCALL                                               'var_export'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                                 
         20      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
Branch analysis from position: 17
filename:       /in/vLG09
function name:  {closure}
number of ops:  27
compiled vars:  !0 = $a, !1 = $b, !2 = $eval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        INIT_FCALL                                               'json_encode'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        CONCAT                                           ~4      '%0A', $3
          6        CONCAT                                           ~5      ~4, '+-vs-+'
          7        INIT_FCALL                                               'json_encode'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $6      
         10        CONCAT                                           ~7      ~5, $6
         11        CONCAT                                           ~8      ~7, '+eval%3A+'
         12        ECHO                                                     ~8
   15    13        ISSET_ISEMPTY_DIM_OBJ                         0  ~9      !0, 'sort_code'
         14      > JMPZ_EX                                          ~9      ~9, ->17
         15    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~10     !1, 'sort_code'
         16        BOOL                                             ~9      ~10
         17    > > JMPZ_EX                                          ~9      ~9, ->22
         18    >   FETCH_DIM_R                                      ~11     !0, 'sort_code'
         19        FETCH_DIM_R                                      ~12     !1, 'sort_code'
         20        IS_SMALLER                                       ~13     ~12, ~11
         21        BOOL                                             ~9      ~13
         22    >   CAST                                          4  ~14     ~9
         23        ASSIGN                                           ~15     !2, ~14
         24        ECHO                                                     ~15
   16    25      > RETURN                                                   !2
   17    26*     > 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/vLG09
function name:  {closure}
number of ops:  24
compiled vars:  !0 = $a, !1 = $b, !2 = $eval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   24     2        INIT_FCALL                                               'json_encode'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        CONCAT                                           ~4      '%0A', $3
          6        CONCAT                                           ~5      ~4, '+-vs-+'
          7        INIT_FCALL                                               'json_encode'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $6      
         10        CONCAT                                           ~7      ~5, $6
         11        CONCAT                                           ~8      ~7, '+eval%3A+'
         12        ECHO                                                     ~8
   25    13        FETCH_DIM_IS                                     ~9      !0, 'sort_code'
         14        COALESCE                                         ~10     ~9
         15        QM_ASSIGN                                        ~10     0
         16        FETCH_DIM_IS                                     ~11     !1, 'sort_code'
         17        COALESCE                                         ~12     ~11
         18        QM_ASSIGN                                        ~12     0
         19        SPACESHIP                                        ~13     ~10, ~12
         20        ASSIGN                                           ~14     !2, ~13
         21        ECHO                                                     ~14
   26    22      > RETURN                                                   !2
   27    23*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.42 ms | 1005 KiB | 16 Q