Forum Moderators: coopster
I have an object that queries the DB and populates an array of result objects as follows:
for ($i=0; $i < $num_results; $i++)
{
$comment = new comment();
$row = mysql_fetch_array($result);
$comment->setContent($row);
array_push($comments_array, $comment);
}
But when I pass this $comments_array to another object it is as if the individual elements of $comments_array are empty.
It's as if array_push($comments_array, $comment); pushed a reference to $comment = new comment(); in the array, such that when the objects go out of scope they are lost.
Any suggestion on how to get array_push($comments_array, $comment); to push objects in the array by copy?
Thanks a lot