Explode string on commas and trim potential spaces from each value

You can do the following using array_map:

$new_arr = array_map('trim', explode(',', $str));

Leave a Comment