Multidimensional arrays
This is one of the most difficult subjects to get my head around... I just don't understand it, and many of the online tutorials don't really get into creating a dynamic multidimensional array, rather, they'll tell us how to parse the array into data we can read, which doesn't make any sense to me.
Does anybody have a simple example of how to create a dynamic multidimensional array? When I say "dynamic" I mean the values need to not be static... I'm stating the obvious now, forgive me. lol
Here's what I'm trying to do... I have three values inside a database... each of these values belongs to a row inside the database. So, what I've come up with thus far is this:
while ($row = mysql_fetch_array($result)){
//each iteration would relate to a row inside the database.
$cart = array(array(id=>$row['id'], project_id=>$row['project_id'], price=>$row['price']));
}
... which seems to put some sort of values somewhere... there was a point where I was able to read a single row of the data, but now I've screwed it all up so I really don't know what's what.
Any help would be super. Thanks!
Does anybody have a simple example of how to create a dynamic multidimensional array? When I say "dynamic" I mean the values need to not be static... I'm stating the obvious now, forgive me. lol
Here's what I'm trying to do... I have three values inside a database... each of these values belongs to a row inside the database. So, what I've come up with thus far is this:
while ($row = mysql_fetch_array($result)){
//each iteration would relate to a row inside the database.
$cart = array(array(id=>$row['id'], project_id=>$row['project_id'], price=>$row['price']));
}
... which seems to put some sort of values somewhere... there was a point where I was able to read a single row of the data, but now I've screwed it all up so I really don't know what's what.
Any help would be super. Thanks!
