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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.