3v4l.org

run code in 300+ PHP versions simultaneously
<?php function startsWith($haystack, $needle) { // search backwards starting from haystack length characters from the end return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; } $example = array(); $example['variable'] = 'abc'; $nextToBeSet = 'var'; $is_exist = false; foreach($example as $k => $v) { if(startsWith($k, $nextToBeSet)) { $is_exist = true; break; } } if($is_exist) echo 'exists'; else echo 'not exists';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
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: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 16
Branch analysis from position: 16
filename:       /in/QBj7A
function name:  (null)
number of ops:  22
compiled vars:  !0 = $example, !1 = $nextToBeSet, !2 = $is_exist, !3 = $v, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN_DIM                                               !0, 'variable'
          2        OP_DATA                                                  'abc'
   12     3        ASSIGN                                                   !1, 'var'
   13     4        ASSIGN                                                   !2, <false>
   14     5      > FE_RESET_R                                       $9      !0, ->16
          6    > > FE_FETCH_R                                       ~10     $9, !3, ->16
          7    >   ASSIGN                                                   !4, ~10
   16     8        INIT_FCALL                                               'startswith'
          9        SEND_VAR                                                 !4
         10        SEND_VAR                                                 !1
         11        DO_FCALL                                      0  $12     
         12      > JMPZ                                                     $12, ->15
   18    13    >   ASSIGN                                                   !2, <true>
   19    14      > JMP                                                      ->16
   14    15    > > JMP                                                      ->6
         16    >   FE_FREE                                                  $9
   23    17      > JMPZ                                                     !2, ->20
   24    18    >   ECHO                                                     'exists'
   23    19      > JMP                                                      ->21
   26    20    >   ECHO                                                     'not+exists'
         21    > > RETURN                                                   1

Function startswith:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/QBj7A
function name:  startsWith
number of ops:  15
compiled vars:  !0 = $haystack, !1 = $needle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        IS_IDENTICAL                                     ~2      !1, ''
          3      > JMPNZ_EX                                         ~2      ~2, ->13
          4    >   INIT_FCALL                                               'strrpos'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        STRLEN                                           ~3      !0
          8        MUL                                              ~4      ~3, -1
          9        SEND_VAL                                                 ~4
         10        DO_ICALL                                         $5      
         11        TYPE_CHECK                                  1018  ~6      $5
         12        BOOL                                             ~2      ~6
         13    > > RETURN                                                   ~2
    6    14*     > RETURN                                                   null

End of function startswith

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.96 ms | 1017 KiB | 15 Q