Convert comma separated string into array

Convert comma separated string into array  we need to use explode php function

Example Below : 
$myString = “15,webtechsource18@gmail.com,sainidaya”;
$myArray = explode(‘,’, $myString);

print_r($myArray);

Output:
Array
(
[0] => 15
[1] => webtechsource18@gmail.com
[2] => sainidaya
)

How explode function works :
The explode() function breaks a string into an array.

Note: “Separator” parameter cannot be an empty String.

Syntax of explode
explode(separator,string)

 

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face – we are here to solve your problems.

I, Dayanand Saini,the founder and chief editor of www.webtechsource.com,have been working as a software engineer from last 4+ years. It's my hobby to learn new things and implement on live environment.

Leave a Reply

Your email address will not be published. Required fields are marked *

44 − 43 =

%d bloggers like this: