3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "Héllo Bob's and Russ’ new-found folks — goodbye"; var_export( array_reduce( preg_match_all("~([^\p{L}`'-]*)([\p{L}`'-]+)~u", $text, $m, PREG_SET_ORDER) ? $m : [], function($result, $m) { static $last = 0; $last += mb_strlen($m[1]); $result[] = [$m[2] => $last]; $last += mb_strlen($m[2]); return $result; }, [] ) );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rHEpZ
function name:  (null)
number of ops:  21
compiled vars:  !0 = $text, !1 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'H%C3%A9llo+Bob%27s+and+Russ%E2%80%99+new-found+folks+%E2%80%94+goodbye'
    5     1        INIT_FCALL                                               'var_export'
    6     2        INIT_FCALL                                               'array_reduce'
    7     3        INIT_FCALL                                               'preg_match_all'
          4        SEND_VAL                                                 '%7E%28%5B%5E%5Cp%7BL%7D%60%27-%5D%2A%29%28%5B%5Cp%7BL%7D%60%27-%5D%2B%29%7Eu'
          5        SEND_VAR                                                 !0
          6        SEND_REF                                                 !1
          7        SEND_VAL                                                 2
          8        DO_ICALL                                         $3      
          9      > JMPZ                                                     $3, ->12
         10    >   QM_ASSIGN                                        ~4      !1
         11      > JMP                                                      ->13
         12    >   QM_ASSIGN                                        ~4      <array>
         13    >   SEND_VAL                                                 ~4
    8    14        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
   14    15        SEND_VAL                                                 ~5
   15    16        SEND_VAL                                                 <array>
    6    17        DO_ICALL                                         $6      
   15    18        SEND_VAR                                                 $6
    5    19        DO_ICALL                                                 
   17    20      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rHEpZ
function name:  {closure}
number of ops:  19
compiled vars:  !0 = $result, !1 = $m, !2 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        BIND_STATIC                                              !2
   10     3        INIT_FCALL                                               'mb_strlen'
          4        FETCH_DIM_R                                      ~3      !1, 1
          5        SEND_VAL                                                 ~3
          6        DO_ICALL                                         $4      
          7        ASSIGN_OP                                     1          !2, $4
   11     8        FETCH_DIM_R                                      ~7      !1, 2
          9        INIT_ARRAY                                       ~8      !2, ~7
         10        ASSIGN_DIM                                               !0
         11        OP_DATA                                                  ~8
   12    12        INIT_FCALL                                               'mb_strlen'
         13        FETCH_DIM_R                                      ~9      !1, 2
         14        SEND_VAL                                                 ~9
         15        DO_ICALL                                         $10     
         16        ASSIGN_OP                                     1          !2, $10
   13    17      > RETURN                                                   !0
   14    18*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.5 ms | 1018 KiB | 17 Q