Page 1 of 1

Split an array on a delimiter

Posted: Thu Jan 31, 2008 7:28 am
by mcmcom
hi all,
new to php - old to programming.
i need to split a delimited string of values. i tried split but it split each character in the string into its own value in an array.

i need somethign like this:
"spaghetti, ice cream, borat"
in an array like
arr[0]spaghetti
arr[1]ice cream
arr[2]borat

how can i perform this ?

thanks,
mcm

Re: Split an array on a delimiter

Posted: Thu Jan 31, 2008 7:34 am
by webspider

Code: Select all

 
$str = "spaghetti, ice cream, borat";
$arr = explode(",", $str);