how to reverse a hudge multidimensional array?
| From: | Etienne Durand | Date: | Wed, 30 Jan 2002 04:07:23 +0000 |
| Subject: | how to reverse a hudge multidimensional array? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-16295@lists.php.net to get a copy of this message | ||
Well i hope someone will be able to give me a solution...
Here s my problem:
I'm working with a hudge mysql table (about 15 columns and 1000000 rows...)
in fact i ve got to count the number of couples
ncompte/naffaire in the
table and finaly calculate the number of couples that appear once, twice....
here is the query i do:
$result = mysql_query("SELECT count(*) FROM datas GROUP BY ncompte,
naffaire");
its result like something like this:
count(*) naffaire ncompte
4 affaire1 compte1
4 affaire2 compte2
1 affaire3 compte3
2 affaire4 compte4
1 affaire5 compte5
(plus many more)
my final result should be:
$result[1] : 2
$result[2] : 1
$result[4] : 2
I manage to do this quite easily but i use a while instruction...
while($row = mysql_fetch_array($result)) {
array_push($suite, $row["count(*)"]);
}
As my table is very long the while takes a lot of time to complete...
So my question is : Is there a solution to return my array as follow :
1 2 3 1 4 7
4 5 6 ===>> 2 5 8 ???
7 8 9 3 6 9
It would allow me to not have to use this long long while....
So if someone could telle me how to modify my query or what instructions to
use to do that...
thx
Etienne