I’m working on an Order Processor for my company and I’m running into some issues.
For each order in our database, I’m creating an Order object that contains all the information of said order (for example: order id, customer address, etc.). And after this I am putting each Object into an array that’s ultimately being passed to a different page where the information is accessed.
Now, if I do a var_dump on each order object, I get the correct values. But if I do a var_dump on the array of objects (lets say of size 100), I only get the last object repeated 100 times.
So:
$order = new Order();
$newOrder = array();
... While Loop to fill orders ...
{
... Fill $order with data ...
$newOrder[] = $order;
}
If I var_dump or print_r $newOrder, I get the last $order I put in, n times. If I print out each order as I go in the while loop, it outputs correctly.
Thanks in advance!
Any help would be greatly appreciated.
$order = new Order(); should have been in the loop. That fixed it.
Thank you tigrang.