3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = "PHP CODING TECH"; $counters = array_fill_keys(explode(' ', $input), 1); // ['PHP' => 1, 'CODING' => 1, 'TECH' => 1] do { $bump = true; // stop after this iteration unless more letters to output foreach ($counters as $word => &$len) { // $len is mod-by-ref for incrementing echo substr($word, 0, $len); // echo letters using $len if ($bump && isset($word[$len])) { // if no $len has been incremented during inner loop... ++$len; // increment this word's $len $bump = false; // permit outer loop to run again } } echo "\n"; // separate outputs } while (!$bump); // while still letters to output....
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 12, Position 2 = 27
Branch analysis from position: 12
2 jumps found. (Code = 126) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 26
Branch analysis from position: 23
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 10
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
Branch analysis from position: 27
filename:       /in/poYvg
function name:  (null)
number of ops:  32
compiled vars:  !0 = $input, !1 = $counters, !2 = $bump, !3 = $len, !4 = $word
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'PHP+CODING+TECH'
    3     1        INIT_FCALL                                               'array_fill_keys'
          2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '+'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $6      
          6        SEND_VAR                                                 $6
          7        SEND_VAL                                                 1
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !1, $7
    6    10    >   ASSIGN                                                   !2, <true>
    7    11      > FE_RESET_RW                                      $10     !1, ->27
         12    > > FE_FETCH_RW                                      ~11     $10, !3, ->27
         13    >   ASSIGN                                                   !4, ~11
    8    14        INIT_FCALL                                               'substr'
         15        SEND_VAR                                                 !4
         16        SEND_VAL                                                 0
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                         $13     
         19        ECHO                                                     $13
    9    20      > JMPZ_EX                                          ~14     !2, ->23
         21    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~15     !4, !3
         22        BOOL                                             ~14     ~15
         23    > > JMPZ                                                     ~14, ->26
   10    24    >   PRE_INC                                                  !3
   11    25        ASSIGN                                                   !2, <false>
    7    26    > > JMP                                                      ->12
         27    >   FE_FREE                                                  $10
   14    28        ECHO                                                     '%0A'
   15    29        BOOL_NOT                                         ~18     !2
         30      > JMPNZ                                                    ~18, ->10
         31    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.16 ms | 1013 KiB | 16 Q