How to push a copy of an object into array in PHP
In PHP 5, objects are passed by reference unless you specifically say otherwise.
Here, you probably want to clone
the object when you add it to the array:
$obj->var1 = 'string1';$obj->var2 = 'string1';$arr[] = clone $obj;$obj->var1 = 'string2';$obj->var2 = 'string2';$arr[] = clone $obj;