3v4l.org

run code in 500+ 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 = 47
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 5
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 20
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 5
Branch analysis from position: 49
Branch analysis from position: 5
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 20
Branch analysis from position: 45
Branch analysis from position: 20
filename:       /in/EbJIK
function name:  (null)
number of ops:  51
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                                                          ->47
   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        FRAMELESS_ICALL_3                strpos              ~16     !0, '+'
         14        OP_DATA                                                      !1
         15        JMP_SET                                              ~17     ~16, ->17
         16        QM_ASSIGN                                            ~17     !2
         17        SUB                                                  ~18     ~17, 1
         18        ASSIGN                                                       !4, ~18
         19      > JMP                                                          ->43
   17    20    >   FETCH_DIM_R                                          ~20     !0, !1
         21        INIT_ARRAY                                           ~21     ~20
         22        FETCH_DIM_R                                          ~22     !0, !4
         23        ADD_ARRAY_ELEMENT                                    ~21     ~22
         24        FETCH_LIST_R                                         $23     ~21, 0
         25        ASSIGN_DIM                                                   !0, !4
         26        OP_DATA                                                      $23
         27        FETCH_LIST_R                                         $25     ~21, 1
         28        ASSIGN_DIM                                                   !0, !1
         29        OP_DATA                                                      $25
         30        FREE                                                         ~21
   18    31        ROPE_INIT                                         8  ~28     !1
         32        ROPE_ADD                                          1  ~28     ~28, '+%3A+'
         33        ROPE_ADD                                          2  ~28     ~28, !4
         34        ROPE_ADD                                          3  ~28     ~28, '+%3A+'
         35        ROPE_ADD                                          4  ~28     ~28, !3
         36        ROPE_ADD                                          5  ~28     ~28, '+%3A+'
         37        ROPE_ADD                                          6  ~28     ~28, !0
         38        ROPE_END                                          7  ~27     ~28, '%0A'
         39        ECHO                                                         ~27
   15    40        PRE_INC                                                      !3
         41        PRE_INC                                                      !1
         42        PRE_DEC                                                      !4
   14    43    >   IS_SMALLER                                                   !1, !4
         44      > JMPNZ                                                        ~35, ->20
   20    45    >   ASSIGN_OP                                         1          !1, !3
    8    46        PRE_INC                                                      !1
    7    47    >   IS_SMALLER                                                   !1, !2
         48      > JMPNZ                                                        ~38, ->5
   22    49    >   ECHO                                                         !0
   23    50      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.57 ms | 2090 KiB | 13 Q