3v4l.org

run code in 500+ PHP versions simultaneously
<?php function isNumberAfter(array $list, $first, $second) { $isFirstFound = false; foreach ($list as $element) { if (!$isFirstFound && $element === $first) { $isFirstFound = true; } elseif ($isFirstFound && $element === $second) { return true; } } return false; } $list = [1, 2, 3, 7, 2]; var_dump(isNumberAfter($list, 1, 7)); var_dump(isNumberAfter($list, 2, 7)); var_dump(isNumberAfter($list, 38, 9)); var_dump(isNumberAfter($list, 1, 1));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2S3rK
function name:  (null)
number of ops:  34
compiled vars:  !0 = $list
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                       !0, <array>
   17     1        INIT_FCALL                                                   'var_dump'
          2        INIT_FCALL                                                   'isnumberafter'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     1
          5        SEND_VAL                                                     7
          6        DO_FCALL                                          0  $2      
          7        SEND_VAR                                                     $2
          8        DO_ICALL                                                     
   18     9        INIT_FCALL                                                   'var_dump'
         10        INIT_FCALL                                                   'isnumberafter'
         11        SEND_VAR                                                     !0
         12        SEND_VAL                                                     2
         13        SEND_VAL                                                     7
         14        DO_FCALL                                          0  $4      
         15        SEND_VAR                                                     $4
         16        DO_ICALL                                                     
   19    17        INIT_FCALL                                                   'var_dump'
         18        INIT_FCALL                                                   'isnumberafter'
         19        SEND_VAR                                                     !0
         20        SEND_VAL                                                     38
         21        SEND_VAL                                                     9
         22        DO_FCALL                                          0  $6      
         23        SEND_VAR                                                     $6
         24        DO_ICALL                                                     
   20    25        INIT_FCALL                                                   'var_dump'
         26        INIT_FCALL                                                   'isnumberafter'
         27        SEND_VAR                                                     !0
         28        SEND_VAL                                                     1
         29        SEND_VAL                                                     1
         30        DO_FCALL                                          0  $8      
         31        SEND_VAR                                                     $8
         32        DO_ICALL                                                     
         33      > RETURN                                                       1

Function isnumberafter:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 20
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 20
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
Branch analysis from position: 16
Branch analysis from position: 10
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/2S3rK
function name:  isNumberAfter
number of ops:  23
compiled vars:  !0 = $list, !1 = $first, !2 = $second, !3 = $isFirstFound, !4 = $element
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
    4     3        ASSIGN                                                       !3, <false>
    5     4      > FE_RESET_R                                           $6      !0, ->20
          5    > > FE_FETCH_R                                                   $6, !4, ->20
    6     6    >   BOOL_NOT                                             ~7      !3
          7      > JMPZ_EX                                              ~7      ~7, ->10
          8    >   IS_IDENTICAL                                         ~8      !4, !1
          9        BOOL                                                 ~7      ~8
         10    > > JMPZ                                                         ~7, ->13
    7    11    >   ASSIGN                                                       !3, <true>
    6    12      > JMP                                                          ->19
    8    13    > > JMPZ_EX                                              ~10     !3, ->16
         14    >   IS_IDENTICAL                                         ~11     !4, !2
         15        BOOL                                                 ~10     ~11
         16    > > JMPZ                                                         ~10, ->19
    9    17    >   FE_FREE                                                      $6
         18      > RETURN                                                       <true>
    5    19    > > JMP                                                          ->5
         20    >   FE_FREE                                                      $6
   13    21      > RETURN                                                       <false>
   14    22*     > RETURN                                                       null

End of function isnumberafter

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.64 ms | 2383 KiB | 18 Q