Re: [PHP] multidimensional array problems

2007-01-19 Thread Larry Garfield
It's actually quite simple. You simply add another layer of grouping. General case: $result = mysql_query("SELECT a, b, c, d FROM foo ORDER BY a, b, c"); while ($record = mysql_fetch_object($result)) { $roster[$record->a][$record->b][] = $record; } ksort($roster); foreach ($roster as $a =>

Re: [PHP] multidimensional array problems

2007-01-19 Thread nitrox .
Ive followed your example on grouping. Im still trying to understand all of the code but ive made great progess on this with your example. Now I have one last issue and this will be solved. Ill remind here what Im trying to achieve I have a table for leagues, lookup table and team roster. There

Re: [PHP] multidimensional array problems

2007-01-13 Thread Jim Lucas
Give this a go $memroster = "SELECT inf_league.game, inf_league.type, inf_member.user_name, inf_member.rank, " . "inf_member.country, inf_member.email " . "FROM inf_league " . "INNER JOIN inf_memberleague ON inf_league.gid = inf_memberleague.l_id " .

Re: [PHP] multidimensional array problems

2007-01-13 Thread Larry Garfield
kup table and member table. Do > you think it would be better possably to do seperate querys and then match > them in php? would that be possable the given the setup i have? > > >From: Larry Garfield <[EMAIL PROTECTED]> > >To: php-general@lists.php.net > >Subject:

Re: [PHP] multidimensional array problems

2007-01-13 Thread Larry Garfield
It's better to just leave the record as an array and read it that way. while ($row = mysql_fetch_assoc($result)) { print "{$row['game']} {$row['type']}\n"; } And so on. You're not actually dealing with a multi-dimensional array yet; $result is an object from which you are extracting data record

Re: [PHP] multidimensional array sort

2005-03-14 Thread Ashley M. Kirchner
Leif Gregory wrote: http://us3.php.net/manual/en/function.array-multisort.php I did go through that, but I can't get it to work and I'm almost willing to bet it's because of the way the array is built. For example, the example on that page says that I should be able to do a sort on $ar[0] an

Re: [PHP] multidimensional array sort

2005-03-14 Thread Leif Gregory
Hello Ashley, Monday, March 14, 2005, 12:12:19 PM, you wrote: A> I need to do a sort on the whole thing in such a way that: A>a) all the Dir#'s are in ascending order, and A>b) all the User#'s are in ascending order with each Dir#, and A>b) all the File#'s are also in a

Re: [PHP] Multidimensional Array manipluation...

2003-01-02 Thread Dhaval Desai
haval Desai <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED] Subject: Re: [PHP] Multidimensional Array manipluation... Date: Thu, 2 Jan 2003 09:30:43 -0800 (PST) > >$test["0"]["hey"] = 1; > >$test["1"]["hi"] = 2; > >$test["2"]

Re: [PHP] Multidimensional Array manipluation...

2003-01-02 Thread Chris Shiflett
> >$test["0"]["hey"] = 1; > >$test["1"]["hi"] = 2; > >$test["2"]["hello"] = 3; > > I want to update $test["0"]["hey"] and set it as 1+1; If you just want to increment the value: $test["0"]["hey"]++; > Also is there any idea on how can we count() the values > in a multi dimensional arrays... Th

Re: [PHP] Multidimensional Array manipluation...

2003-01-02 Thread Dhaval Desai
rrays... Thanx From: Chris Shiflett <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: Dhaval Desai <[EMAIL PROTECTED]>, [EMAIL PROTECTED] Subject: Re: [PHP] Multidimensional Array manipluation... Date: Thu, 2 Jan 2003 09:04:27 -0800 (PST) --- Dhaval Desai <[EMAIL PROTECTED]>

Re: [PHP] Multidimensional Array manipluation...

2003-01-02 Thread Chris Shiflett
--- Dhaval Desai <[EMAIL PROTECTED]> wrote: > $test[0] = "hey"; > $test[1] = "hi"; > $test[2] = "hello"; > > Now I want to hold various values in $test[0]["hey"] = > "1" and $test[1]["hi"] = "2" and $test[2]["hello"] = "3" Try this instead: $test["0"]["hey"] = 1; $test["1"]["hi"] = 2; $test["2"]

Re: [PHP] multidimensional array

2002-04-19 Thread Miguel Cruz
On Fri, 19 Apr 2002, Rodrigo Peres wrote: > In order to avoid many left joins I took an aproach that I didn't know > if it's good, but I couldn't figure out another way. If my cliente has > 10 phone numbers I buld an array, serialize it and store in database, so > I didn't have to create another t

RE: [PHP] Multidimensional array construction

2001-12-07 Thread Tim Ward
L PROTECTED]] Sent: 04 December 2001 15:22 To: PHP List; 'Mike Eheler' Subject: RE: [PHP] Multidimensional array construction Good day, Thanks to all who replied. This isn't quite what I needed, though. I _have_ the array (or delim

RE: [PHP] Multidimensional array construction

2001-12-04 Thread Darren Gamble
= Darren Gamble Planner, Regional Services Shaw Cablesystems GP 630 - 3rd Avenue SW Calgary, Alberta, Canada T2P 4L4 (403) 781-4948 -Original Message- From: Mike Eheler [mailto:[EMAIL PROTECTED]] Sent: Monday, December 03, 2001 5:30 PM To: Martin Towell Cc: 'Darren Gamble'; P

Re: [PHP] Multidimensional array construction

2001-12-03 Thread Mike Eheler
I did something like this recently. Here's how I did it: $some_value1 = 'Hello World'; $myarray['foo']['bar']['green']['apple'] = $some_value1; function get_opt($arr, $keys,$sep=':') { $var = $arr; $tmp = split($sep,$keys); foreach ($tmp as $k => $v) { $var = $var[$v]; }

RE: [PHP] Multidimensional array construction

2001-12-03 Thread Jim
oops. That's not correct. I wish it was though! ;) >This might be interesting ... > >The function extract() allows you to extract all values from an >array and prefix them with a specified string. What I didn't know >until just a second ago was that you can supply a function as a >string, so

RE: [PHP] Multidimensional array construction

2001-12-03 Thread Jim
This might be interesting ... The function extract() allows you to extract all values from an array and prefix them with a specified string. What I didn't know until just a second ago was that you can supply a function as a string, so ... $my_array = array("a","b","c","d",array("a","b","c","d

RE: [PHP] Multidimensional array construction

2001-12-03 Thread Martin Towell
I was thinking that you could use a "pointer to var", eg: $var = 'myarray["foo"]["bar"]["red"]["apple"]'; // this would obviously be created dynamically, hard coded for testing $$var = $some_value1; echo $myarray["foo"]["bar"]["red"]["apple"]; but when I tried it, it didn't work :(