Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class A
- {
- public $key;
- public $parent;
- }
- class B
- {
- public $value;
- public $objects;
- }
- $a1 = new A();
- $a1->key = 'a1';
- $a2 = new A();
- $a2->key = 'a2';
- $a2->parent = $a1;
- $a3 = new A();
- $a3->key = 'a3';
- $a3->parent = $a2;
- $b = new B();
- $b->objects = [$a1, $a2, $a3];
- $b->value = 100;
- someFunction($b);
- [
- 'a1' => ['a2' => ['a3' => 100]]
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement