3v4l.org

run code in 300+ 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:  8
compiled vars:  !0 = $slug
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'trim'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%2C+%09%0A%0D%00%0B'
          4        DO_ICALL                                         $1      
          5        IS_NOT_IDENTICAL                                 ~2      $1, ''
          6      > RETURN                                                   ~2
    8     7*     > 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:  16
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        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 '%22%22'
          4        SEND_VAL                                                 ''
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                         $3      
          9        ASSIGN                                                   !1, $3
   14    10        INIT_FCALL                                               'array_filter'
         11        SEND_VAR                                                 !1
         12        SEND_VAL                                                 'is_valid_plugin_slug'
         13        DO_ICALL                                         $5      
         14      > RETURN                                                   $5
   15    15*     > RETURN                                                   null

End of function parse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.63 ms | 1403 KiB | 24 Q