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 = intval($a/3); $bcol = 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/tPpnK
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%2FtPpnK%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%2FtPpnK%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tPpnK
function name:  {closure}
number of ops:  23
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        ASSIGN                                                   !4, ~13
    9    11        DIV                                              ~15     !1, 3
         12        CAST                                          4  ~16     ~15
         13        ASSIGN                                                   !5, ~16
   10    14        IS_EQUAL                                                 !4, !5
         15      > JMPZ                                                     ~18, ->19
         16    >   SUB                                              ~19     !2, !3
         17        QM_ASSIGN                                        ~20     ~19
         18      > JMP                                                      ->21
         19    >   SUB                                              ~21     !4, !5
         20        QM_ASSIGN                                        ~20     ~21
         21    > > RETURN                                                   ~20
   15    22*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.7 ms | 1396 KiB | 17 Q