simplysandeep Posted November 18, 2011 Share Posted November 18, 2011 Hi Guys I'm returning to programming after 5 years, almost a newbie. I have a field(column) in a MySQL database table that has strings of characters separated by a delimiter (||). For example: (TOM||PAUL||HARRIS) I would like to separate the strings into an array. Something like this: ARRAY[0] = 'TOM'; ARRAY[1]='PAUL'; ARRAY[3]='HARRIS'; Can some one tell me how to do this? TIA. Link to comment https://forums.phpfreaks.com/topic/251355-separating-a-string-of-characters-separated-by-into-an-array-of-elements/ Share on other sites More sharing options...
nethnet Posted November 18, 2011 Share Posted November 18, 2011 Use the explode() function. <?php $string = "TOM||PAUL||HARRIS"; $array = explode("||", $string); echo $array[0]; // Echoes "TOM" ?> Link to comment https://forums.phpfreaks.com/topic/251355-separating-a-string-of-characters-separated-by-into-an-array-of-elements/#findComment-1289197 Share on other sites More sharing options...
simplysandeep Posted November 18, 2011 Author Share Posted November 18, 2011 Thanks mate... That was super fast. Link to comment https://forums.phpfreaks.com/topic/251355-separating-a-string-of-characters-separated-by-into-an-array-of-elements/#findComment-1289199 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.