PHP Coding Tips

Showing posts with label string to array. Show all posts
Showing posts with label string to array. Show all posts

Tuesday, August 7, 2012

How to split an array to parts by comma or special character (string to array) ?

Use explode function for this job:$names = 'John,Margaret,Thomas'; $namesArray = explode( ',' , $names ); echo $namesArray[0]; echo $namesArray[1]; echo $namesArray[2];You can also use a character sequence to split string like a "splitplace"