listToArray()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
justgetaway
Forum Newbie
Posts: 3
Joined: Tue Jul 09, 2002 2:04 pm

listToArray()

Post by justgetaway »

I would like to convert a comma separated list to an array.

$myList = "value1, value2, value3, ...";

$myArray = listToArray($myList);

I don't see a native function for this, but being inexperienced with PHP, I may have missed it. I could build it with regular expressions, but thought this must be a pretty common function, so I thought I would check here first.

Greg Alton
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Post by RandomEngy »

Code: Select all

$myArray = explode(", ", $myList);
justgetaway
Forum Newbie
Posts: 3
Joined: Tue Jul 09, 2002 2:04 pm

Post by justgetaway »

Thanks for saving me time and redundancy!

Greg Alton
Post Reply