3v4l.org

run code in 500+ PHP versions simultaneously
<?php $data = '"slug,1", slug 2, test, "slug, 3", "", ",",'; function is_valid_plugin_slug($slug) { return trim($slug, ", \t\n\r\0\x0B") !== ''; } function parse($data) { $plugins = str_getcsv( str_replace('""', '', $data ) ); return array_filter($plugins, 'is_valid_plugin_slug'); } echo "Bare str_getcsv:\n"; $plugins = str_getcsv( $data ); var_dump( $plugins ); echo "\n\nstr_getcsv with filtering:\n"; var_dump( parse( $data ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YWsue
function name:  (null)
number of ops:  17
compiled vars:  !0 = $data, !1 = $plugins
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%22slug%2C1%22%2C+slug+2%2C+test%2C+%22slug%2C+3%22%2C+%22%22%2C+%22%2C%22%2C'
   18     1        ECHO                                                         'Bare+str_getcsv%3A%0A'
   19     2        INIT_FCALL                                                   'str_getcsv'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $3      
          5        ASSIGN                                                       !1, $3
   20     6        INIT_FCALL                                                   'var_dump'
          7        SEND_VAR                                                     !1
          8        DO_ICALL                                                     
   22     9        ECHO                                                         '%0A%0Astr_getcsv+with+filtering%3A%0A'
   23    10        INIT_FCALL                                                   'var_dump'
         11        INIT_FCALL                                                   'parse'
         12        SEND_VAR                                                     !0
         13        DO_FCALL                                          0  $6      
         14        SEND_VAR                                                     $6
         15        DO_ICALL                                                     
         16      > RETURN                                                       1

Function is_valid_plugin_slug:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YWsue
function name:  is_valid_plugin_slug
number of ops:  5
compiled vars:  !0 = $slug
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
    7     1        FRAMELESS_ICALL_2                trim                ~1      !0, '%2C+%09%0A%0D%00%0B'
          2        IS_NOT_IDENTICAL                                     ~2      ~1, ''
          3      > RETURN                                                       ~2
    8     4*     > RETURN                                                       null

End of function is_valid_plugin_slug

Function parse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YWsue
function name:  parse
number of ops:  13
compiled vars:  !0 = $data, !1 = $plugins
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
   12     1        INIT_FCALL                                                   'str_getcsv'
          2        FRAMELESS_ICALL_3                str_replace         ~2      '%22%22', ''
          3        OP_DATA                                                      !0
          4        SEND_VAL                                                     ~2
          5        DO_ICALL                                             $3      
          6        ASSIGN                                                       !1, $3
   14     7        INIT_FCALL                                                   'array_filter'
          8        SEND_VAR                                                     !1
          9        SEND_VAL                                                     'is_valid_plugin_slug'
         10        DO_ICALL                                             $5      
         11      > RETURN                                                       $5
   15    12*     > RETURN                                                       null

End of function parse

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
175.22 ms | 2093 KiB | 17 Q