3v4l.org

run code in 300+ PHP versions simultaneously
<?php $longString = 'I like apple. You like oranges. We like fruit. I like meat, also.'; $arrayWords = explode(' ', $longString); $maxLineLength = 18; $currentLength = 0; $index = 0; foreach ($arrayWords as $word) { // +1 because the word will receive back the space in the end that it loses in explode() $wordLength = strlen($word) + 1; if (($currentLength + $wordLength) <= $maxLineLength) { $arrayOutput[$index] .= $word . ' '; $currentLength += $wordLength; } else { $index += 1; $currentLength = $wordLength; $arrayOutput[$index] = $word; } } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 27
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 27
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 22
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/a5F8n
function name:  (null)
number of ops:  29
compiled vars:  !0 = $longString, !1 = $arrayWords, !2 = $maxLineLength, !3 = $currentLength, !4 = $index, !5 = $word, !6 = $wordLength, !7 = $arrayOutput
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'I+like+apple.+You+like+oranges.+We+like+fruit.+I+like+meat%2C+also.'
    5     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '+'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $9      
          5        ASSIGN                                                   !1, $9
    7     6        ASSIGN                                                   !2, 18
    9     7        ASSIGN                                                   !3, 0
   10     8        ASSIGN                                                   !4, 0
   12     9      > FE_RESET_R                                       $14     !1, ->27
         10    > > FE_FETCH_R                                               $14, !5, ->27
   14    11    >   STRLEN                                           ~15     !5
         12        ADD                                              ~16     ~15, 1
         13        ASSIGN                                                   !6, ~16
   16    14        ADD                                              ~18     !3, !6
         15        IS_SMALLER_OR_EQUAL                                      ~18, !2
         16      > JMPZ                                                     ~19, ->22
   17    17    >   CONCAT                                           ~21     !5, '+'
         18        ASSIGN_DIM_OP                .=               8          !7, !4
         19        OP_DATA                                                  ~21
   19    20        ASSIGN_OP                                     1          !3, !6
         21      > JMP                                                      ->26
   21    22    >   ASSIGN_OP                                     1          !4, 1
   23    23        ASSIGN                                                   !3, !6
   25    24        ASSIGN_DIM                                               !7, !4
         25        OP_DATA                                                  !5
   12    26    > > JMP                                                      ->10
         27    >   FE_FREE                                                  $14
   29    28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.18 ms | 1396 KiB | 15 Q