Re: Performance of multidimensional arrays vs many variables

From: Date: Wed, 28 Jan 2004 20:31:17 +0000
Subject: Re: Performance of multidimensional arrays vs many variables
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-176116@lists.php.net to get a copy of this message
Hi John If you have a large number of Users using this system, your save map for sessions will grow in space, using some resources If it's very large pieces of information, i would advise you to store this info in a database. That's doomed to be more effective. Eric "John Schulz" <subscription@ambientshadow.com> wrote in message news:4FD92530-51CA-11D8-A318-000A95ACF916@ambientshadow.com... > I'm planning to use a very large multidimensional array to store data > for grouping quantities of Products. This information needs to be > carried from page to page in a session. Here's a part of the array's > hierarchy for an example: > > grouping (array) > - owner => 'name' > - message => 'text' > - package (array) > -- 1st package (array) > --- box => $boxTypeID > --- inspector => $employeeID > --- contents (array) > ---- $productID => $quantity > > So, for example, if I want to access the contents of the third package: > $array_of_productIDs = $grouping['package'][3]['contents']; > > Great for organization, but seems prone to inefficiencies. For > example, I need to look though each Package for a Product ID to find > how many of that Product that have been Packaged, compare that with the > quantity of that Product ID in the work order, and display to the user > the quantity that hasn't yet been packaged. > > I'm also concerned about the memory usage for such a deep array; would > it take more memory than the same data broken up into many, simpler > variables? > > I've thought of using simpler variables (e.g., $package1, $package2, > $p1contents, etc.). However, since there are many pieces of > structurally-similar data (the Contents of a Package could have any > number of Product IDs and and Quantities), and some elements have many > pieces of related data (both a Box Type and Inspector for each > Package), arrays seem to be the logical choice. > > Am I worrying about this too much? ;-) Are arrays the best solution > for this sort of problem?

« previous php.general (#176116) next »