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; } $session = array( 'current_page_12' => 'abc', 'current_page_qw1' => 'xyz', 'hello' => 'world', 'current_page_23d' => 'mno', 'example' => '112' ); foreach($session as $key => $value) { if(startsWith($key, 'current_page_')) unset($session[$key]); } print_r($session);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 11
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 10
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/uh4HK
function name:  (null)
number of ops:  16
compiled vars:  !0 = $session, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, <array>
   16     1      > FE_RESET_R                                       $4      !0, ->11
          2    > > FE_FETCH_R                                       ~5      $4, !1, ->11
          3    >   ASSIGN                                                   !2, ~5
   18     4        INIT_FCALL                                               'startswith'
          5        SEND_VAR                                                 !2
          6        SEND_VAL                                                 'current_page_'
          7        DO_FCALL                                      0  $7      
          8      > JMPZ                                                     $7, ->10
   19     9    >   UNSET_DIM                                                !0, !2
   16    10    > > JMP                                                      ->2
         11    >   FE_FREE                                                  $4
   22    12        INIT_FCALL                                               'print_r'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
         15      > 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/uh4HK
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:
148.28 ms | 1015 KiB | 16 Q