php objects problem
Posted: Sun Oct 28, 2007 5:43 am
i am new to onjects when it comes to php but the problem i amhaving seems really weird.
i have this class
i instantiate the object as
and create a array
and then i have this loop
and finally i want to see if my data is passed ok
while he echoes in the loop show 0 1 2 3 as it should the echoes after the loop all show 3...
anyone knows why this is happening??
i have this class
Code: Select all
class thing_obj{
var $id;
var $address;
var $area;
var $price;
var $size;
}Code: Select all
$temp_obj = new thing_obj();Code: Select all
$array = Array();Code: Select all
$i=0;
while($i<4){
$temp_obj->id = $i;
$array[$i] = $temp_house;
echo $array[$i]->id;
$i++;
}Code: Select all
echo $array['0']->id;
echo "--";
echo $array['1']->id;
echo "--";
echo $array['2']->id;
echo "--";
echo $array['3']->id;
anyone knows why this is happening??