3v4l.org

run code in 500+ PHP versions simultaneously
<?php $string = 'test text long long test text'; $array = explode(' ',$string); $finalString = ''; foreach($array as $key=> $arr){ if($key ==0){ $finalString = $arr; }else{ if($arr == $array[$key-1]){ $finalString .='-'.$arr; }else{ $finalString .=' '.$arr; } } } echo $finalString;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 24
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/FVSRU
function name:  (null)
number of ops:  27
compiled vars:  !0 = $string, !1 = $array, !2 = $finalString, !3 = $arr, !4 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'test+text+long+long+test+text'
    5     1        INIT_FCALL                                                   'explode'
          2        SEND_VAL                                                     '+'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $6      
          5        ASSIGN                                                       !1, $6
    7     6        ASSIGN                                                       !2, ''
    8     7      > FE_RESET_R                                           $9      !1, ->24
          8    > > FE_FETCH_R                                           ~10     $9, !3, ->24
          9    >   ASSIGN                                                       !4, ~10
    9    10        IS_EQUAL                                                     !4, 0
         11      > JMPZ                                                         ~12, ->14
   10    12    >   ASSIGN                                                       !2, !3
    9    13      > JMP                                                          ->23
   12    14    >   SUB                                                  ~14     !4, 1
         15        FETCH_DIM_R                                          ~15     !1, ~14
         16        IS_EQUAL                                                     !3, ~15
         17      > JMPZ                                                         ~16, ->21
   13    18    >   CONCAT                                               ~17     '-', !3
         19        ASSIGN_OP                                         8          !2, ~17
   12    20      > JMP                                                          ->23
   15    21    >   CONCAT                                               ~19     '+', !3
         22        ASSIGN_OP                                         8          !2, ~19
    8    23    > > JMP                                                          ->8
         24    >   FE_FREE                                                      $9
   21    25        ECHO                                                         !2
   22    26      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
132.34 ms | 480 KiB | 8 Q