3v4l.org

run code in 500+ PHP versions simultaneously
<?php function extractWantedStuff($input) { $output = []; $sections = explode('""', $input); foreach ($sections as $key => $section) { if ($key % 2 != 0) { $section = str_replace(',', '', $section); } $output[] = $section; } return implode('""', $output); } $fullstring = ',""Word1, Word2"" and another thing ,""Word3, Word4""'; echo extractWantedStuff($fullstring);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IhKVQ
function name:  (null)
number of ops:  6
compiled vars:  !0 = $fullstring
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                       !0, '%2C%22%22Word1%2C+Word2%22%22+and+another+thing+%2C%22%22Word3%2C+Word4%22%22'
   18     1        INIT_FCALL                                                   'extractwantedstuff'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $2      
          4        ECHO                                                         $2
          5      > RETURN                                                       1

Function extractwantedstuff:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 16
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/IhKVQ
function name:  extractWantedStuff
number of ops:  23
compiled vars:  !0 = $input, !1 = $output, !2 = $sections, !3 = $section, !4 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        ASSIGN                                                       !1, <array>
    6     2        INIT_FCALL                                                   'explode'
          3        SEND_VAL                                                     '%22%22'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $6      
          6        ASSIGN                                                       !2, $6
    7     7      > FE_RESET_R                                           $8      !2, ->19
          8    > > FE_FETCH_R                                           ~9      $8, !3, ->19
          9    >   ASSIGN                                                       !4, ~9
    8    10        MOD                                                  ~11     !4, 2
         11        IS_NOT_EQUAL                                                 ~11, 0
         12      > JMPZ                                                         ~12, ->16
    9    13    >   FRAMELESS_ICALL_3                str_replace         ~13     '%2C', ''
         14        OP_DATA                                                      !3
         15        ASSIGN                                                       !3, ~13
   11    16    >   ASSIGN_DIM                                                   !1
         17        OP_DATA                                                      !3
    7    18      > JMP                                                          ->8
         19    >   FE_FREE                                                      $8
   13    20        FRAMELESS_ICALL_2                implode             ~16     '%22%22', !1
         21      > RETURN                                                       ~16
   14    22*     > RETURN                                                       null

End of function extractwantedstuff

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.23 ms | 1890 KiB | 15 Q