Jump to content

Array grouping


mrras25

Recommended Posts

I dont know why I cant remember this of all basic things to do (to much perl I guess). I assumed that if I looped through my query to build an array it would just append it to right area.

 

I have a query that returns data like this:

2Bell|HP|6047|45807

2Bell|HP|13757|45807

2Bell|HP|5134|45807

2Bell|HP|3087|45807

2Bell|HP|2063|45807

2Bell|HP|2063|45807

2Bell|HP|2063|45807

2Bell|HP|2062|45805

2Bell|HP|2137|45807

2Bell|HP|2064|45807

2Bell|HP|2064|45807

2Bell|HP|2064|45807

.........

as you can see there a lot of identical "sites (2Bell)" and "Vendors (HP)" the idea is to group and build an array that would look like this:

 

$array (2Bell => (HP =>(size1,size2,size3),EMC =>(size1,size2,size3)),Bothell =>(HP =>(size1,size2,size3),...);

 

the code i have so far:

<code>

 

while($data = $DB->Fetch($query)) {

      $dtarr[] = array($data["location"] => array($data["vender"] => array($data["array"] => array($data["alloc"],$data["unalloc"]))));

}

</code>

Link to comment
https://forums.phpfreaks.com/topic/81573-array-grouping/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.