[wp-trac] [WordPress Trac] #44212: Add a new helper function for comma- or space-separated lists
WordPress Trac
noreply at wordpress.org
Mon May 28 15:11:02 UTC 2018
#44212: Add a new helper function for comma- or space-separated lists
--------------------------------------+------------------------------
Reporter: keesiemeijer | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+------------------------------
Comment (by keesiemeijer):
Yes, it could be used with `trim()`, but you still have to use the
`PREG_SPLIT_NO_EMPTY` flag otherwise it returns a non empty array for
empty strings.
{{{#!php
<?php
$list = preg_split( '/[\s,]+/', trim( $list ), -1, PREG_SPLIT_NO_EMPTY );
}}}
The `parse_wp_list()` function is there so you can get values from comma-
or space-separated lists without the sanitation from
`wp_parse_slug_list()` or `wp_parse_id_list`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44212#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list