Andrew Bellamy

caffeine + nicotine = asp.net (c#), sql, php goodness
along with the standard web tech thrown in

Value Object Class

commentNo Comments personAndy folderCategories: code tagTags: PHP

Value class that hold values. Can be used with any class that returns an array of values

Usage
$temp = new ValueObject(
			array(
				"value1" => "value",
				"value2" => 2,
				"value3" => 123.123,
				"value4" => "value"
			)
		);
echo $temp->value1;

Code

class ValueObject {

	private $properties = array();

	public function __construct($values = array()) {
		foreach($values as $key => $value)
			$this->properties[$key] = $value;
	}

	public function __set($key = "", $value = "") {
		$this->properties[$key] = $value;
	}

	public function __get($key = "") {
		if(array_key_exists($key, $this->properties))
			return $this->properties[$key];
	}
}

your go