order/reorder pull out data from arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have an array that i would like to sort and reorder based on a simple
critera.  I already order the data but I would like to break the data now
into sections by customer id, so one customer has 5 things and another
customer has one.  How can I do that with an array.

$data = orders($id,$status);
$c = count($data);
for($i=0; $i<$c; $i++) {
$orderid = $data[$i]['orderid'];
$customerid = $data[$i]['customerid'];
$name = $data[$i]['name'];
print $orderid.' - '.$customerid.' - '.$name.'<br>';
}

What it is currently is all the orders are ordered by the customer number,
however I would like to group it a little nicer on the output.

Current:
1234 - blah blah blah - Y - 3, 01234
1235 - blah blah blah - N - 6, 01234
1236 - blah blah blah - N - 6, 01234
1237 - blah blah blah - Y - 6, 11256
1238 - blah blah blah - N - 6, 22589
1239 - blah blah blah - N - 6, 22589
1240 - blah blah blah - Y - 6, 22589
1241 - blah blah blah - N - 6, 22589

Would like:
01234 - The Customer 1
1234 - blah blah blah - Y - 3
1235 - blah blah blah - N - 6
1236 - blah blah blah - N - 6

11256 - The Customer 2
1237 - blah blah blah - Y - 6

22589 - The Customer 3
1238 - blah blah blah - N - 6
1239 - blah blah blah - N - 6
1240 - blah blah blah - Y - 6
1241 - blah blah blah - N - 6

Anyway I can do that?

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux