Is it possible to set property values of an object using a foreach loop?
I mean something equivalent to:
foreach($array as $key=>$value) {
$array[$key] = get_new_value();
}
EDIT: My example code did nothing, as @YonatanNir and @gandra404 pointed out, so I changed it a little bit so it reflects what I meant
foreachit must be anarrayto loop through. Rather generate the array the convert it to object.$this->$key = $valuemaybe ? where$keyis the name of the property you want to check ?foreach (get_object_vars($obj) as $key => $value) { ... }?