I’m looking for a way to achieve the results below. I’m constricted to using this class and it’s methods to achieve it.
final class Trade {
private $users_id;
private $adj_id;
public function display() {
var_dump($this);
}
public function setData($form_results) {
foreach ($form_results as $var => $value) {
$this->{$var} = $value;
}
}
public function getData() {
return get_object_vars($this);
}
}
The problem is calling get_object_vars() inside the class method. As expected it ignores the private variables I have set and returns an array of all the class variables both public and private due to its scope.
I’m trying to have the method return just the public anonymous variables. Is there a way I can do this?
Try to use
See details on http://www.php.net/manual/en/language.oop5.iterations.php