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 ) );
Output for git.master, git.master_jit, rfc.property-hooks
Bare str_getcsv: array(7) { [0]=> string(6) "slug,1" [1]=> string(7) " slug 2" [2]=> string(5) " test" [3]=> string(7) "slug, 3" [4]=> string(0) "" [5]=> string(1) "," [6]=> string(0) "" } str_getcsv with filtering: array(4) { [0]=> string(6) "slug,1" [1]=> string(7) " slug 2" [2]=> string(5) " test" [3]=> string(7) "slug, 3" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
64.34 ms | 402 KiB | 8 Q