PHP: Accessing an object property with a variable.
- by Peter
Let's assume I have an array of object properties I'd like to access:
$properties = array('foo', 'bar');
I'd like to loop through the object and access these properties dynamically (specifically, I'm trying to dynamically handle missing JSON elements based on an array of expected elements):
foreach ($data as $item) {
foreach ($properties as…