Community warning: If that string comes from a csv file, use of str_getcsv() instead is strictly advised, as suggested in this answer

Try explode:

$myString = "9,admin@example.com,8";
$myArray = explode(',', $myString);
print_r($myArray);

Output :

Array
(
    [0] => 9
    [1] => admin@example.com
    [2] => 8
)
Answer from Matthew Groves on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ split-a-comma-delimited-string-into-an-array-in-php
Split a comma delimited string into an array in PHP - GeeksforGeeks
July 11, 2025 - In this approach we Initialize variables to hold the current word and the final array, then loop through each character in the string then we append characters to the current word until a comma is found then add the current word to the array and reset it...
Discussions

How to convert items in array to a comma separated string in PHP? - Stack Overflow
Possible Duplicate: How to create comma separated list from array in PHP? Given this array: $tags = array('tag1','tag2','tag3','tag4','...'); How do I generate this string (using PHP): $tags = ' More on stackoverflow.com
๐ŸŒ stackoverflow.com
php - comma-separated string to array - Stack Overflow
I'm looking for the simplest way to take a single variable such as: $variable = 'left,middle,right'; and write it to an array(); split at the commas. More on stackoverflow.com
๐ŸŒ stackoverflow.com
php - Convert comma separated string into array - Stack Overflow
I have a comma separated string, which consists of a list of tags and want to convert it to array to get a link for every tag. Example: $string = 'html,css,php,mysql,javascript'; I want to make i... More on stackoverflow.com
๐ŸŒ stackoverflow.com
April 30, 2011
php - Array to comma separated string? - Stack Overflow
Through foreach, all array values are now comma separated. As of now, output will be test 10, test 11,. So, remove extra comma which trail in the end through rtrim(). ... Save this answer. ... Show activity on this post. There are many ways to skin this cat -- Here's one: More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
PHP Freaks
forums.phpfreaks.com โ€บ php coding โ€บ php coding help
how to convert comma separated string to array in array - PHP Coding Help - PHP Freaks
October 5, 2017 - My original string items separated with two delimiters ( | and ,). I used the following function for this purpose. function makeKeyboard($str){ $array = array(); $array = explode('|', $str); foreach($array as $key => $str) { $arra...
๐ŸŒ
CodeSpeedy
codespeedy.com โ€บ home โ€บ convert comma separated string into array in php
Convert Comma Separated String into Array in PHP - CodeSpeedy
February 23, 2020 - In the code, we use the PHP explode() function. explode function of PHP breaks a string into an array. Below is the syntax of this function: ... This is also required parameter. This string will be split into an array.
๐ŸŒ
GitHub
gist.github.com โ€บ sanikamal โ€บ 2211eb930339cb241d3b54e1e98b67d0
Convert Comma Separated String into Array in PHP ยท GitHub
Convert Comma Separated String into Array in PHP. GitHub Gist: instantly share code, notes, and snippets.
๐ŸŒ
Reactgo
reactgo.com โ€บ php-comma-separated-strring-to-array
How to split comma separated string to array in PHP | Reactgo
February 2, 2023 - We can split the comma (,) separated string to an array by using the built-in explode() function in PHP.
๐ŸŒ
Useful Snippets
snippets.khromov.se โ€บ home โ€บ convert comma separated values to array in php
Convert comma separated values to array in PHP - Useful Snippets
September 19, 2015 - A short snippet you can use: /** * @param $string - Input string to convert to array * @param string $separator - Separator to separate by (default: ,) * * @return array */ function comma_separated_to_array($string, $separator = ',') { //Explode ...
Find elsewhere
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ php-program-to-split-a-given-comma-delimited-string-into-an-array-of-values
PHP program to split a given comma delimited string into an array of values
<?php $my_string = "apple, banana, cherry, date"; $my_str_arr = array_map('trim', explode(",", $my_string)); print_r($my_str_arr); ?> Array ( [0] => apple [1] => banana [2] => cherry [3] => date ) Use explode() for simple comma-separated strings and ...
๐ŸŒ
W3Docs
w3docs.com โ€บ php
How to Split a Comma Delimited String to an Array with PHP | W3Docs
The explode() function is supported on PHP 4, PHP 5, PHP 7, and PHP 8. It splits a string into an array using a specified delimiter. The function returns an array of strings, where each element is a substring created by splitting the original ...
๐ŸŒ
CSS-Tricks
css-tricks.com โ€บ snippets โ€บ php โ€บ convert-comma-separated-string-into-array
Convert Comma Separated String into Array | CSS-Tricks
October 30, 2009 - โ†’ PHP ยท โ†’ Convert Comma Separated String into Array ยท Chris Coyier on Sep 13, 2009 Updated on Oct 30, 2009 ยท Easy way to turn a CSV file into a parseable array. <?php $str="foo,bar,baz,bat"; $arr=explode(",",$str); // print_r($arr); ?> Psst! Create a DigitalOcean account and get $200 in free credit for cloud-based hosting and services.
๐ŸŒ
Linux Hint
linuxhint.com โ€บ php-convert-array-comma-separated-string
Linux Hint โ€“ Linux Hint
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
๐ŸŒ
Tutorial Republic
tutorialrepublic.com โ€บ faq โ€บ how-to-convert-comma-separated-string-into-an-array-in-javascript.php
How to Convert Comma Separated String into an Array in JavaScript
You can use the JavaScript split() method to split a string using a specific separator such as comma (,), space, etc. If separator is an empty string, the string is converted to an array of characters.
๐ŸŒ
php.cn
m.php.cn โ€บ home โ€บ backend development โ€บ php problem โ€บ how to convert comma string to array in php
How to convert comma string to array in php-PHP Problem-php.cn
April 25, 2023 - Theexplode() function can split a string into an array, where the delimiter can be a comma, space, or any other character. The syntax of this function is as follows: array explode ( string $delimiter , string $string [, int $limit ] ) Among ...
๐ŸŒ
Thebarton
thebarton.org โ€บ fort lauderdale seo โ€บ blog โ€บ turn a php array or object into a comma separated string
PHP array or object into a comma separated string | Florida Developer
April 20, 2016 - We can also take this a step further and turn the array keys of the associated array into a comma separated array: function to_string($data, $glue=', ', $type='field') { $output = ''; if(!empty($data) && count($data) > 0) { if($type == 'key') { $values = array_keys($data); } else { $values = array_values($data); } $output = join($glue, $values); } return $output; } $myArray = array('blue' => 'Blue', 'yellow' => 'Yellow'); $str = to_string($myArray, $type='keys'); echo $str;
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 40237263 โ€บ array-to-comma-separated-string โ€บ 40237634
php - Array to comma separated string? - Stack Overflow
Through foreach, all array values are now comma separated. As of now, output will be test 10, test 11,. So, remove extra comma which trail in the end through rtrim(). ... Save this answer. ... Show activity on this post. There are many ways to skin this cat -- Here's one: <?php $out = ''; foreach ($array as $arrayItem) { $out .= $arrayItem['b_title'] . ', '; } // Remove the extraneous ", " from the $out string...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ how-to-create-comma-separated-list-from-array-in-php
How to Create Comma Separated List from an Array in PHP? - GeeksforGeeks
July 11, 2025 - <?php // Declare an array and initialize it $Array = array(0, 1, 2, 3, 4, 5, 6, 7); // Display the array elements print_r($Array); // Use implode() function to join // comma in the array $List = implode(', ', $Array); // Display the comma separated ...