Need help separating a row in a table into an array[solved]

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
The-Master
Forum Commoner
Posts: 45
Joined: Sun Aug 07, 2005 9:51 am
Location: Israel

Need help separating a row in a table into an array[solved]

Post by The-Master »

Hi, i wanted to know how i can separate a row in a table to an array...
the row is for example: "me, you, they, us" and i want that after every "," a new array value will be made...

Code: Select all

$arr=array("one" => "me", "two" => "you", "three" => "they", "four" => us);
Last edited by The-Master on Thu Apr 20, 2006 1:38 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The-Master
Forum Commoner
Posts: 45
Joined: Sun Aug 07, 2005 9:51 am
Location: Israel

Post by The-Master »

you just saved me a big amount of code lines... i wanted to do this:

Code: Select all

<?php
$num=0;
$r=...       //the database stuff... (mouse_1, mouse_2, ..._3)
$mice=$r['mice'];
$mice_total=array($mice);
foreach($mice as &$mouse) {
echo "$mouse[$num]";
++$num;
}
?>
thanks!
Post Reply