any way to iterate the fields in a class

From: Date: Thu, 25 Nov 2010 08:20:37 +0000
Subject: any way to iterate the fields in a class
Groups: php.general 
Request: Send a blank email to php-general+get-309658@lists.php.net to get a copy of this message
Actually, what I am seeking is how to assign values to the fields in a class via an array. I have tried like this. However failed. I have a class. *class book{ var name;* *var price;* *}* * * And I have got an array. *$array=array('name'=>'harry potter','price'=>'$122');* By using function *extract(), *I assign the values to $name and $price while not $this->name and $this->price, which is not what I want. So I am thinking iterating the fields in an array and assign the values each by each through an array. Is there any way to assign values to the fields in a class via an array. Thanks in advance!

« previous php.general (#309658) next »