3v4l.org

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

End of function extractwantedstuff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.69 ms | 1020 KiB | 17 Q