I have a simple object (or array) like this...
stdClass Object ( [people] => Array ( [0] => stdClass Object ( [name] => 'John', [age] => 50, ) [0] => stdClass Object ( [name] => 'Martin', [age] => 47, ) ) And I can easily loop through it using foreach like this
foreach ($people as $person) { echo $person->name . '<br>'; } But I would somehow like to have a shorter way to echo all names with something like this...
print_each($people->name) And it would do exactly the same thing with only 1 short line of code as my 3 lines of foreach code did.
Is there a function like this or how would we go about creating a function like that?