3v4l.org

run code in 300+ PHP versions simultaneously
<?php $value = 53; $items = array(1, 22, 77, 53, 34, 51, 56); $runtimes = 0; function find($needle, array $haystack, $cursor = 0) { $GLOBAL['runtimes'] ++; if (!isset($haystack[$cursor])) { return false; } if ($needle === $haystack[$cursor]) { return $cursor; } return find($needle, $haystack, $cursor + 1); } $retval = find($value, $items); printf($runtimes . PHP_EOL); var_dump($retval);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KH48E
function name:  (null)
number of ops:  16
compiled vars:  !0 = $value, !1 = $items, !2 = $runtimes, !3 = $retval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 53
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, 0
   20     3        INIT_FCALL                                               'find'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $7      
          7        ASSIGN                                                   !3, $7
   21     8        INIT_FCALL                                               'printf'
          9        CONCAT                                           ~9      !2, '%0A'
         10        SEND_VAL                                                 ~9
         11        DO_ICALL                                                 
   22    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !3
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function find:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KH48E
function name:  find
number of ops:  21
compiled vars:  !0 = $needle, !1 = $haystack, !2 = $cursor, !3 = $GLOBAL
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      0
    8     3        FETCH_DIM_RW                                     $4      !3, 'runtimes'
          4        PRE_INC                                                  $4
    9     5        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !1, !2
          6        BOOL_NOT                                         ~7      ~6
          7      > JMPZ                                                     ~7, ->9
   10     8    > > RETURN                                                   <false>
   13     9    >   FETCH_DIM_R                                      ~8      !1, !2
         10        IS_IDENTICAL                                             !0, ~8
         11      > JMPZ                                                     ~9, ->13
   14    12    > > RETURN                                                   !2
   17    13    >   INIT_FCALL_BY_NAME                                       'find'
         14        SEND_VAR_EX                                              !0
         15        SEND_VAR_EX                                              !1
         16        ADD                                              ~10     !2, 1
         17        SEND_VAL_EX                                              ~10
         18        DO_FCALL                                      0  $11     
         19      > RETURN                                                   $11
   18    20*     > RETURN                                                   null

End of function find

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.87 ms | 1403 KiB | 18 Q