3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numbers = array( 0, 0, 4, 0, 0, 0, 0, 0, 0, 2, 3, 0, 3, 0, 0, 0, 6, 0, 0, 6, 0, 0, 0, 2, 0, 2, 1, 0, 0, 0, 0, 0, 0, 5, 0, 0); function getNumber($numbers, $row, $column){ $position = $row * 6 - (6 - $column); // the two 6s are your consts. return $numbers[$position - 1]; // -1 because arrays count from 0, not 1. }; $number = getNumber($numbers, 1, 3); print_r($number);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4mP3r
function name:  (null)
number of ops:  11
compiled vars:  !0 = $numbers, !1 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   17     1        INIT_FCALL                                               'getnumber'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 1
          4        SEND_VAL                                                 3
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !1, $3
   19     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function getnumber:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4mP3r
function name:  getNumber
number of ops:  11
compiled vars:  !0 = $numbers, !1 = $row, !2 = $column, !3 = $position
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   13     3        MUL                                              ~4      !1, 6
          4        SUB                                              ~5      6, !2
          5        SUB                                              ~6      ~4, ~5
          6        ASSIGN                                                   !3, ~6
   14     7        SUB                                              ~8      !3, 1
          8        FETCH_DIM_R                                      ~9      !0, ~8
          9      > RETURN                                                   ~9
   15    10*     > RETURN                                                   null

End of function getnumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.42 ms | 1402 KiB | 16 Q