Jump to content

sub array from larger array


agravayne

Recommended Posts

Hello All,

 

I was wondering if the following is possible. I have a page that is makeing several large sql queries and dropping them into arrays but much of the data is duplicated so what I would rather do is drop all the data into one large array them create smaller arays on the fly as they are needed from this. Here is a simple example.

 

The larger array would contain the following keys - Serial Number, Type, Group, Name

 

I would then for example need to create an array of all the different distinct group names. So for example this would result in Group1, Group2 etc. I would them for each of these loop back though the large array and get al the serial numbers accociated with each group. So all serials nubers whose group is Group1.

 

Firstly I cannot see how to create the sub array of groups. Secondly how would I do the search in the array. It wouuld be the equivalent of a sql query select * from array where Group=Group1 if you see what I mean.

 

Secondly - would using arrays like this be significantly faster than the multiple queries I am now using?

 

Hope this is clear.

 

Scott

Link to comment
https://forums.phpfreaks.com/topic/115992-sub-array-from-larger-array/
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.