RE: [PHP] Fast code to partially flatten an array based on several keys?

2002-06-30 Thread Martin Towell
sort function (uses the quick sort algorithm if I remember rightly) -Original Message- From: Morgan Grubb [mailto:[EMAIL PROTECTED]] Sent: Monday, July 01, 2002 1:16 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Fast code to partially flatten an array based on several keys? Martin, I said I&

Re: [PHP] Fast code to partially flatten an array based on several keys?

2002-06-30 Thread Morgan Grubb
']] > = $row['page_views']; > > so you'd get something like (manually created result...): > ( > [645] => Array > ( > [35073] => Array > ( > [1] => 10 > [0] =&g

Re: [PHP] Fast code to partially flatten an array based on several keys?

2002-06-27 Thread Tom Rogers
missed a couple of quotes and braces there :) while ($row = mysql_fetch_assoc($result)) { $vehicles[$row['dealer_id']][$row['vehicle_id']]['views'][] = $row['page_views']; } At 02:03 PM 28/06/2002 +1000, Tom Rogers wrote: >Hi >I would do it this way (untested) > >while ($row = mysql_fetch_ass

Re: [PHP] Fast code to partially flatten an array based on several keys?

2002-06-27 Thread Tom Rogers
Hi I would do it this way (untested) while ($row = mysql_fetch_assoc($result)) { $vehicles[$row['dealer_id][$row['vehicle_id]['views'][] = $row['page_views']; } should end up something like this ( [645] => Array ( [35073] => Array ([

Re: [PHP] Fast code to partially flatten an array based on several keys?

2002-06-27 Thread Morgan Grubb
dealer_id']][$row['vehicle_id']][$row['company_id']] > = $row['page_views']; > > so you'd get something like (manually created result...): > ( > [645] => Array > ( > [35073] => Array > ( >

RE: [PHP] Fast code to partially flatten an array based on several keys?

2002-06-27 Thread Martin Towell
ow['page_views']; so you'd get something like (manually created result...): ( [645] => Array ( [35073] => Array ( [1] => 10 [0] => 6 ) ) ) -Original Message- From: Morgan G

Re: [PHP] Fast code to partially flatten an array based on several keys?

2002-06-27 Thread Morgan Grubb
Martin, Here's an example of what I implemented (simplified down again). As you can see, it's hideously simple and not optimized in the least. It works well on small datasets, but you can see by looking at it that large datasets get exponentially slower. while ($row = mysql_fetch_assoc($re

Re: [PHP] Fast code to partially flatten an array based on several keys?

2002-06-27 Thread Morgan Grubb
Martin, I'm happy to do it either way, but I can't think of a really fast way to do it, which is why I thought I'd ask. =) Morgan Grubb. "Martin Towell" <[EMAIL PROTECTED]> wrote in message 6416776FCC55D511BC4E0090274EFEF508A54E@EXCHANGE">news:6416776FCC55D511BC4E0090274EFEF508A54E@EXCHANGE...

RE: [PHP] Fast code to partially flatten an array based on several keys?

2002-06-27 Thread Martin Towell
this sort of merging would be easier to do when you create the array (unless you need the other format for something else?) -Original Message- From: Morgan Grubb [mailto:[EMAIL PROTECTED]] Sent: Friday, June 28, 2002 11:09 AM To: [EMAIL PROTECTED] Subject: [PHP] Fast code to partially fla