<?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 ) );
preferences:
59.18 ms | 408 KiB | 5 Q