$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"
PHP Coding tips & tricks. Function & error explanation, coding style, how tos etc. Short notes posted directly from developer work environment.
PHP Coding Tips
Showing posts with label split. Show all posts
Showing posts with label split. 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:
Subscribe to:
Posts (Atom)