There is such code:
$r2 = array(); for($i = 0; $i < count($r); $i++) {//$r это массив объектов Room $rt = new Room(); $rt = $r[$i]; array_push($r2, $rt); } echo "\n ".$r[0]->x; //допустим 42 $r2[0]->x = 13; echo "\n ".$r[0]->x; //13! How to make so that to change a copy of objects and values in the original did not change? Thanks for the help.
$rtvariable, and on the next line you are trying to put something in the$rtarray under the $ i key, which is a bit strange)array_push($r2, clone($rt));- jekaby