Or upon further examination ! But not sure how to rewrite as I didn't understand the $key purpose in the original ! Warning Reference of a $value and the last array element remain even after the foreach loop. It is recommended to destroy it by unset(). Reference: http://php.net/manual/en/control-structures.foreach.php unset($value); // break the reference with the last element On Jun 30, 2012, at 9:17 PM, Brian Marple wrote: > What is wrong with this code? It is as simple as all get out yet it doesn't > work!!! Does anyone have any clues? > > > <?php > > class myObj > { > private $values = array(); > > public function __construct() { > $values['ONE']=1; > $values['TWO']=2; > $values['THREE']=3; > > foreach ($values as $key => $value) > echo $key.'=>'.$value.'<br />'; > } > > //Return key value if assigned, else return not assigned > public function get($key) { > if (isset($values[$key])){ > return $values[$key]; > } > return 'Not assigned!'; > } > > } > > $var = new myObj; > echo 'The value is: '.$var->get('ONE'); > > ?> > > -- > Brian Marple > Systems Analyst > > > > Lee T. Davy - Mini Play Cool Games play@xxxxxxxxxxxxx