3v4l.org

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

End of function extractwantedstuff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.01 ms | 1020 KiB | 17 Q