Do you want to split the string of text into the array after every comma or space or dot, etc in PHP?
Then you came to the right place.
Here:
We have posted the simple guide and code snippets that will help you to split a comma delimited string into an array.
Read Also: Convert Amount in Digits or Numbers to Words using PHP
So let’s get to the point without wasting time.
How to Split Comma Separated String into an Array in PHP?
To split the string into the array we need to use the php function called: explode()
The explode function helps to split any string value into an array. The function with parameters looks like this. explode ( $delimiter , $string )
So how would we use this to split into the array?
Let’s say you have the list of student names written into one string and is separated with the comma, for split those names we will write the code like below.
Code Snippets to Split String into Array.
The above code put the comma-separated names into the array. Below is the output of the above code.
Output
That’s it.
Hope the above guide helped you.
Do share this guide: Comma seperated string to Array.