I want to get &$object changed in array stuff. I feel PHP seems to work in a strange way.
private function set_property($propertyPath, &$object, $value)
{
$targetObject = &$object;
if (is_object($targetObject) && property_exists($targetObject, $lastProperty)) {
// &$object is successfully modified
$targetObject->{"aaa"} = $value;
} else if (isset($targetObject) && is_array($targetObject)) {
// &$object fails in being modified
$targetObject["aaa"] = $value;
}
}
I am doing this one, but the thing is that I want to walk through an object and array mixed stuff.
How can I get/set a property dynamically having a path without recursion?
$lastPropertycome from?ArrayObject? How does it fails? Error or just not modified? You can't simply access object with[]notation, it's not JS