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?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to