3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [1,2,3,4,5,6,7,8,9]; $expect = [1,4,7,2,5,8,3,6,9]; $a = usort($array, function ($a, $b){ $arow = 3 - $a%3; $brow = 3 - $b%3; $acol = 3 - intval($a/3); $bcol = 3 - intval($b/3); return $acol == $bcol?($arow - $brow):$acol - $bcol; }); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BDQId
function name:  (null)
number of ops:  12
compiled vars:  !0 = $array, !1 = $expect, !2 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'usort'
          3        SEND_REF                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBDQId%3A5%240'
   15     5        SEND_VAL                                                 ~5
          6        DO_ICALL                                         $6      
    5     7        ASSIGN                                                   !2, $6
   17     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FBDQId%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BDQId
function name:  {closure}
number of ops:  25
compiled vars:  !0 = $a, !1 = $b, !2 = $arow, !3 = $brow, !4 = $acol, !5 = $bcol
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        MOD                                              ~6      !0, 3
          3        SUB                                              ~7      3, ~6
          4        ASSIGN                                                   !2, ~7
    7     5        MOD                                              ~9      !1, 3
          6        SUB                                              ~10     3, ~9
          7        ASSIGN                                                   !3, ~10
    8     8        DIV                                              ~12     !0, 3
          9        CAST                                          4  ~13     ~12
         10        SUB                                              ~14     3, ~13
         11        ASSIGN                                                   !4, ~14
    9    12        DIV                                              ~16     !1, 3
         13        CAST                                          4  ~17     ~16
         14        SUB                                              ~18     3, ~17
         15        ASSIGN                                                   !5, ~18
   10    16        IS_EQUAL                                                 !4, !5
         17      > JMPZ                                                     ~20, ->21
         18    >   SUB                                              ~21     !2, !3
         19        QM_ASSIGN                                        ~22     ~21
         20      > JMP                                                      ->23
         21    >   SUB                                              ~23     !4, !5
         22        QM_ASSIGN                                        ~22     ~23
         23    > > RETURN                                                   ~22
   15    24*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FBDQId%3A5%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.64 ms | 1400 KiB | 17 Q