Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Person
- {
- protected $name;
- public function __construct(string $name)
- {
- $this->name = $name;
- }
- public function __get($prop)
- {
- return $this->$prop;
- }
- public function __isset($prop) : bool
- {
- return isset($this->$prop);
- }
- }
- $people = [
- new Person('Fred'),
- new Person('Jane'),
- new Person('John'),
- ];
- print_r(array_column($people, 'name'));
Add Comment
Please, Sign In to add comment