Friday, August 8, 2014

Split string into array using comma delimiter in PHP

You may use explode function.

PHP Code:

$str="Banana,Apple,Mango,Coconut";

$val= explode(',', $str);

var_dump($val);

Output:

array(4) { [0]=> string(6) "Banana" 
[1]=> string(5) "Apple"
[2]=> string(5) "Mango" 
[3]=> string(7) "Coconut" }

Thanks.
It will help you.

If you feel better please comments.

No comments:

Post a Comment