3v4l.org

run code in 500+ PHP versions simultaneously
<?php $needles = ['a','c','r','r']; $haystacks = ['carr','car','arc','ra','c','abc','do','aa','rr', 'rrr']; $result = []; foreach ($haystacks as $i => $haystack) { foreach ($needles as $needle) { $haystack = preg_replace("/$needle/", '', $haystack, 1); } if (!$haystack) { $result[] = $haystacks[$i]; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 26
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 26
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 19
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 25
Branch analysis from position: 19
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/u4FI1
function name:  (null)
number of ops:  31
compiled vars:  !0 = $needles, !1 = $haystacks, !2 = $result, !3 = $haystack, !4 = $i, !5 = $needle
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, <array>
    6     2        ASSIGN                                                       !2, <array>
    7     3      > FE_RESET_R                                           $9      !1, ->26
          4    > > FE_FETCH_R                                           ~10     $9, !3, ->26
          5    >   ASSIGN                                                       !4, ~10
    8     6      > FE_RESET_R                                           $12     !0, ->19
          7    > > FE_FETCH_R                                                   $12, !5, ->19
    9     8    >   INIT_FCALL                                                   'preg_replace'
          9        ROPE_INIT                                         3  ~14     '%2F'
         10        ROPE_ADD                                          1  ~14     ~14, !5
         11        ROPE_END                                          2  ~13     ~14, '%2F'
         12        SEND_VAL                                                     ~13
         13        SEND_VAL                                                     ''
         14        SEND_VAR                                                     !3
         15        SEND_VAL                                                     1
         16        DO_ICALL                                             $16     
         17        ASSIGN                                                       !3, $16
    8    18      > JMP                                                          ->7
         19    >   FE_FREE                                                      $12
   11    20        BOOL_NOT                                             ~18     !3
         21      > JMPZ                                                         ~18, ->25
   12    22    >   FETCH_DIM_R                                          ~20     !1, !4
         23        ASSIGN_DIM                                                   !2
         24        OP_DATA                                                      ~20
    7    25    > > JMP                                                          ->4
         26    >   FE_FREE                                                      $9
   15    27        INIT_FCALL                                                   'var_export'
         28        SEND_VAR                                                     !2
         29        DO_ICALL                                                     
         30      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.31 ms | 1897 KiB | 15 Q