Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. <?php
  2.  
  3. class A
  4. {
  5. public $key;
  6. public $parent;
  7. }
  8.  
  9. class B
  10. {
  11. public $value;
  12. public $objects;
  13. }
  14.  
  15. $a1 = new A();
  16. $a1->key = 'a1';
  17. $a2 = new A();
  18. $a2->key = 'a2';
  19. $a2->parent = $a1;
  20. $a3 = new A();
  21. $a3->key = 'a3';
  22. $a3->parent = $a2;
  23.  
  24. $b = new B();
  25. $b->objects = [$a1, $a2, $a3];
  26. $b->value = 100;
  27. someFunction($b);
  28.  
  29. [
  30. 'a1' => ['a2' => ['a3' => 100]]
  31. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement