3v4l.org

run code in 500+ PHP versions simultaneously
<?php $payload = [ ['other_value_y' => 'y', 'reference' => '423-52', 'other_value_x' => 'x'], ['other_value_y' => 'y', 'reference' => '223-52', 'other_value_x' => 'x'], ['other_value_y' => 'y', 'reference' => '5423-52', 'other_value_x' => 'x'], ['other_value_y' => 'y', 'reference' => '823-52', 'other_value_x' => 'x'], ['other_value_y' => 'y', 'reference' => '123-52', 'other_value_x' => 'x'], ]; usort($payload, static function (array $a, array $b) { if (!isset($a['reference']) || !isset($b['reference'])) { throw new \RuntimeException('Missing array key "reference"', 1671615426); } // "Remove all characters except digits, plus and minus sign." // (consequence `-123-45-67` is treated as (negative) `-1234567`) // sse https://www.php.net/manual/en/filter.filters.sanitize.php return filter_var($a['reference'], FILTER_SANITIZE_NUMBER_INT) <=> filter_var($b['reference'], FILTER_SANITIZE_NUMBER_INT); }); print_r($payload);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OZ7VD
function name:  (null)
number of ops:  10
compiled vars:  !0 = $payload
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   10     1        INIT_FCALL                                                   'usort'
          2        SEND_REF                                                     !0
          3        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
   19     4        SEND_VAL                                                     ~2
   10     5        DO_ICALL                                                     
   21     6        INIT_FCALL                                                   'print_r'
          7        SEND_VAR                                                     !0
          8        DO_ICALL                                                     
          9      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/OZ7VD
function name:  {closure:/in/OZ7VD:10}
number of ops:  27
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   11     2        ISSET_ISEMPTY_DIM_OBJ                             0  ~2      !0, 'reference'
          3        BOOL_NOT                                             ~3      ~2
          4      > JMPNZ_EX                                             ~3      ~3, ->8
          5    >   ISSET_ISEMPTY_DIM_OBJ                             0  ~4      !1, 'reference'
          6        BOOL_NOT                                             ~5      ~4
          7        BOOL                                                 ~3      ~5
          8    > > JMPZ                                                         ~3, ->14
   12     9    >   NEW                                                  $6      'RuntimeException'
         10        SEND_VAL_EX                                                  'Missing+array+key+%22reference%22'
         11        SEND_VAL_EX                                                  1671615426
         12        DO_FCALL                                          0          
         13      > THROW                                             0          $6
   17    14    >   INIT_FCALL                                                   'filter_var'
         15        FETCH_DIM_R                                          ~8      !0, 'reference'
         16        SEND_VAL                                                     ~8
         17        SEND_VAL                                                     519
         18        DO_ICALL                                             $9      
   18    19        INIT_FCALL                                                   'filter_var'
         20        FETCH_DIM_R                                          ~10     !1, 'reference'
         21        SEND_VAL                                                     ~10
         22        SEND_VAL                                                     519
         23        DO_ICALL                                             $11     
         24        SPACESHIP                                            ~12     $9, $11
         25      > RETURN                                                       ~12
   19    26*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
155.9 ms | 1869 KiB | 16 Q