3v4l.org

run code in 500+ PHP versions simultaneously
<?php $names = ['viktor', 'kate']; $message = 'I had :apple::apple::apple::apple: :apple:<@Viktor><@Kate>took:apple::apple: and later <@viktor> took again:apple:but not <@kate>'; $res = []; foreach ($names as $name) { preg_match_all("/(?:<@$name>(?:<@)?+|\G(?<!^))(?:(?!<@).)*?:apple:/i", $message, $matches); $res[$name] = count($matches[0]); } print_r($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/O0IKl
function name:  (null)
number of ops:  23
compiled vars:  !0 = $names, !1 = $message, !2 = $res, !3 = $name, !4 = $matches
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, 'I+had+%3Aapple%3A%3Aapple%3A%3Aapple%3A%3Aapple%3A+%3Aapple%3A%3C%40Viktor%3E%3C%40Kate%3Etook%3Aapple%3A%3Aapple%3A+and+later+%3C%40viktor%3E+took+again%3Aapple%3Abut+not+%3C%40kate%3E'
    6     2        ASSIGN                                                       !2, <array>
    7     3      > FE_RESET_R                                           $8      !0, ->18
          4    > > FE_FETCH_R                                                   $8, !3, ->18
    8     5    >   INIT_FCALL                                                   'preg_match_all'
          6        ROPE_INIT                                         3  ~10     '%2F%28%3F%3A%3C%40'
          7        ROPE_ADD                                          1  ~10     ~10, !3
          8        ROPE_END                                          2  ~9      ~10, '%3E%28%3F%3A%3C%40%29%3F%2B%7C%5CG%28%3F%3C%21%5E%29%29%28%3F%3A%28%3F%21%3C%40%29.%29%2A%3F%3Aapple%3A%2Fi'
          9        SEND_VAL                                                     ~9
         10        SEND_VAR                                                     !1
         11        SEND_REF                                                     !4
         12        DO_ICALL                                                     
    9    13        FETCH_DIM_R                                          ~14     !4, 0
         14        COUNT                                                ~15     ~14
         15        ASSIGN_DIM                                                   !2, !3
         16        OP_DATA                                                      ~15
    7    17      > JMP                                                          ->4
         18    >   FE_FREE                                                      $8
   11    19        INIT_FCALL                                                   'print_r'
         20        SEND_VAR                                                     !2
         21        DO_ICALL                                                     
         22      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.4 ms | 1598 KiB | 15 Q