Parsing a Variable

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
JohnDigweed
Forum Newbie
Posts: 18
Joined: Sun Mar 28, 2004 6:24 pm
Location: root/user/hell

Parsing a Variable

Post by JohnDigweed »

i have a variable called

$var="150, 2, 2";

I want to split those 3 numbers into seperate variables. How would I go about doing that?

Thanks.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

$vars = explode(',', $var);
foreach($vars as $number){
echo trim($number);
}
Post Reply