3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "I am a boy like desired and expected"; for ( $offset = 0, $length = strlen($string); $offset < $length; ++$offset ) { $offset += $string[$offset] === ' '; echo "word at offset $offset, call strpos()\n"; for ( $swaps = 0, $wordEnd = (strpos($string, ' ', $offset) ?: $length) - 1; $offset < $wordEnd; ++$swaps, ++$offset, --$wordEnd ) { [$string[$wordEnd], $string[$offset]] = [$string[$offset], $string[$wordEnd]]; echo "$offset : $wordEnd : $swaps : $string\n"; } $offset += $swaps; } echo $string;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 5
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 23
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 5
Branch analysis from position: 52
Branch analysis from position: 5
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 23
Branch analysis from position: 48
Branch analysis from position: 23
filename:       /in/EbJIK
function name:  (null)
number of ops:  54
compiled vars:  !0 = $string, !1 = $offset, !2 = $length, !3 = $swaps, !4 = $wordEnd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'I+am+a+boy+like+desired+and+expected'
    6     1        ASSIGN                                                   !1, 0
          2        STRLEN                                           ~7      !0
          3        ASSIGN                                                   !2, ~7
          4      > JMP                                                      ->50
   10     5    >   FETCH_DIM_R                                      ~9      !0, !1
          6        IS_IDENTICAL                                     ~10     ~9, '+'
          7        ASSIGN_OP                                     1          !1, ~10
   11     8        ROPE_INIT                                     3  ~13     'word+at+offset+'
          9        ROPE_ADD                                      1  ~13     ~13, !1
         10        ROPE_END                                      2  ~12     ~13, '%2C+call+strpos%28%29%0A'
         11        ECHO                                                     ~12
   13    12        ASSIGN                                                   !3, 0
         13        INIT_FCALL                                               'strpos'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 '+'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $16     
         18        JMP_SET                                          ~17     $16, ->20
         19        QM_ASSIGN                                        ~17     !2
         20        SUB                                              ~18     ~17, 1
         21        ASSIGN                                                   !4, ~18
         22      > JMP                                                      ->46
   17    23    >   FETCH_DIM_R                                      ~20     !0, !1
         24        INIT_ARRAY                                       ~21     ~20
         25        FETCH_DIM_R                                      ~22     !0, !4
         26        ADD_ARRAY_ELEMENT                                ~21     ~22
         27        FETCH_LIST_R                                     $23     ~21, 0
         28        ASSIGN_DIM                                               !0, !4
         29        OP_DATA                                                  $23
         30        FETCH_LIST_R                                     $25     ~21, 1
         31        ASSIGN_DIM                                               !0, !1
         32        OP_DATA                                                  $25
         33        FREE                                                     ~21
   18    34        ROPE_INIT                                     8  ~28     !1
         35        ROPE_ADD                                      1  ~28     ~28, '+%3A+'
         36        ROPE_ADD                                      2  ~28     ~28, !4
         37        ROPE_ADD                                      3  ~28     ~28, '+%3A+'
         38        ROPE_ADD                                      4  ~28     ~28, !3
         39        ROPE_ADD                                      5  ~28     ~28, '+%3A+'
         40        ROPE_ADD                                      6  ~28     ~28, !0
         41        ROPE_END                                      7  ~27     ~28, '%0A'
         42        ECHO                                                     ~27
   15    43        PRE_INC                                                  !3
         44        PRE_INC                                                  !1
         45        PRE_DEC                                                  !4
   14    46    >   IS_SMALLER                                               !1, !4
         47      > JMPNZ                                                    ~35, ->23
   20    48    >   ASSIGN_OP                                     1          !1, !3
    8    49        PRE_INC                                                  !1
    7    50    >   IS_SMALLER                                               !1, !2
         51      > JMPNZ                                                    ~38, ->5
   22    52    >   ECHO                                                     !0
   23    53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
238.5 ms | 1007 KiB | 14 Q