3v4l.org

run code in 300+ 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 = 22
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 22
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 17
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/asqDf
function name:  extractWantedStuff
number of ops:  29
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, ->22
          9    > > FE_FETCH_R                                               $9, !4, ->22
    9    10    > > JMPZ                                                     !3, ->17
   10    11    >   INIT_FCALL                                               'str_replace'
         12        SEND_VAL                                                 '%2C'
         13        SEND_VAL                                                 ''
         14        SEND_VAR                                                 !4
         15        DO_ICALL                                         $10     
         16        ASSIGN                                                   !4, $10
   12    17    >   ASSIGN_DIM                                               !1
         18        OP_DATA                                                  !4
   13    19        BOOL_NOT                                         ~13     !3
         20        ASSIGN                                                   !3, ~13
    8    21      > JMP                                                      ->9
         22    >   FE_FREE                                                  $9
   15    23        INIT_FCALL                                               'implode'
         24        SEND_VAL                                                 '%22%22'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $15     
         27      > RETURN                                                   $15
   16    28*     > RETURN                                                   null

End of function extractwantedstuff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
247.93 ms | 1014 KiB | 17 Q