3v4l.org

run code in 500+ PHP versions simultaneously
<?php function extractWantedStuff($input) { $output = []; $sections = explode('""', $input); $changeThisSection = false; foreach ($sections as $section) { if ($changeThisSection) { $section = str_replace(',', '', $section); } $output[] = $section; $changeThisSection = !$changeThisSection; } 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/asqDf
function name:  (null)
number of ops:  6
compiled vars:  !0 = $fullstring
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                       !0, '%2C%22%22Word1%2C+Word2%22%22+and+another+thing+%2C%22%22Word3%2C+Word4%22%22'
   20     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 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 14
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/asqDf
function name:  extractWantedStuff
number of ops:  23
compiled vars:  !0 = $input, !1 = $output, !2 = $sections, !3 = $changeThisSection, !4 = $section
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        ASSIGN                                                       !3, <false>
    8     8      > FE_RESET_R                                           $9      !2, ->19
          9    > > FE_FETCH_R                                                   $9, !4, ->19
    9    10    > > JMPZ                                                         !3, ->14
   10    11    >   FRAMELESS_ICALL_3                str_replace         ~10     '%2C', ''
         12        OP_DATA                                                      !4
         13        ASSIGN                                                       !4, ~10
   12    14    >   ASSIGN_DIM                                                   !1
         15        OP_DATA                                                      !4
   13    16        BOOL_NOT                                             ~13     !3
         17        ASSIGN                                                       !3, ~13
    8    18      > JMP                                                          ->9
         19    >   FE_FREE                                                      $9
   15    20        FRAMELESS_ICALL_2                implode             ~15     '%22%22', !1
         21      > RETURN                                                       ~15
   16    22*     > RETURN                                                       null

End of function extractwantedstuff

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
198.68 ms | 1890 KiB | 15 Q