I have a project in codeigniter but isn't releveant.
I have to search inside many external server cars with some search criteria like (sell zone, price, model...).
I make a query in xml to some external server that response to me with an xml, now I have create a model foreach provider (external server).
Into my controller I pass to each model search criteria and return me an array nested like that:
$cars = array(
'car' = array('id' => '', 'name' => '', 'year' => '', 'color' => ''...),
'optional' = array('car_id' => '','key' => ''....),
'variant' = array('car_id' => '','key' => ''....),
);
Main array contain three array inside with many key and value, each optional refer to a a car with car_id
, each variant refer to a car with car_id
.
When return me this array for each model I make a merge because the array that I have created is standard like this:
$car_array = array();
$car_provider1 = $this->provider1->getCar();
$car_provider2 = $this->provider2->getCar();
array_merge_recursive($car_array, $car_provider1, $car_provider2);
Now I have a big array standard with all car of my provider, it can be a very large array with three array inside because depends on the search criteria.
Well my question is that: Having a big nested array final like mine can I have a problem of memory or slow speed?
Is better to use an spl class? Like ArrayIterator
or something like that?
Because I have to pass the final array to the controller and after I have to pass that to my view. I transform each array into a json before print the page because I use backbone to print all.
But my question is: is better to have a big array nested or there is some spl class to manage all this data? (I need only a container to store data, transfomr after into json, nd make some check like: I have an equal car delete it, or an optional that I don't want, something to check or search inside it).
Is a big array a good choice for my goal?