3v4l.org

run code in 500+ PHP versions simultaneously
<?php $string = "This is a string"; $words = []; $spaces = []; foreach (preg_split('~( +)~', $string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $s) { if (ctype_space($s)) { $spaces[] = strlen($s); } else { $words[] = $s; } } var_export([ 'words' => $words, 'spaces' => $spaces ]);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 22
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 22
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/5HTej
function name:  (null)
number of ops:  29
compiled vars:  !0 = $string, !1 = $words, !2 = $spaces, !3 = $s
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'This+is+a++++string'
    5     1        ASSIGN                                                       !1, <array>
    6     2        ASSIGN                                                       !2, <array>
    8     3        INIT_FCALL                                                   'preg_split'
          4        SEND_VAL                                                     '%7E%28+%2B%29%7E'
          5        SEND_VAR                                                     !0
          6        SEND_VAL                                                     -1
          7        SEND_VAL                                                     3
          8        DO_ICALL                                             $7      
          9      > FE_RESET_R                                           $8      $7, ->22
         10    > > FE_FETCH_R                                                   $8, !3, ->22
    9    11    >   INIT_FCALL                                                   'ctype_space'
         12        SEND_VAR                                                     !3
         13        DO_ICALL                                             $9      
         14      > JMPZ                                                         $9, ->19
   10    15    >   STRLEN                                               ~11     !3
         16        ASSIGN_DIM                                                   !2
         17        OP_DATA                                                      ~11
    9    18      > JMP                                                          ->21
   12    19    >   ASSIGN_DIM                                                   !1
         20        OP_DATA                                                      !3
    8    21    > > JMP                                                          ->10
         22    >   FE_FREE                                                      $8
   16    23        INIT_FCALL                                                   'var_export'
   17    24        INIT_ARRAY                                           ~13     !1, 'words'
   18    25        ADD_ARRAY_ELEMENT                                    ~13     !2, 'spaces'
         26        SEND_VAL                                                     ~13
   16    27        DO_ICALL                                                     
   19    28      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.5 ms | 2035 KiB | 16 Q