Created
August 3, 2020 13:13
-
-
Save pecuchet/1aac006594d35d929dc9ff53223a2f8f to your computer and use it in GitHub Desktop.
Split a comma separated string into an array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('array_commas')) { | |
/** | |
* Split a comma separated string into an array. | |
* @param string $str | |
* @return array | |
*/ | |
function array_commas(string $str): array | |
{ | |
$str = explode(',', $str); | |
$str = array_map('trim', $str); | |
return array_filter($str); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment