Advertisement
Guest User

Untitled

a guest
May 25th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. <?php
  2. class X {
  3. public $name;
  4. public function __construct($name) {
  5. $this->name = $name;
  6. }
  7.  
  8. # This must be defined in order to have array_diff() working
  9. #public function __toString() {
  10. # return $this->name;
  11. #}
  12. }
  13.  
  14. $a = new X("A");
  15. $b = new X("B");
  16. $c = new X("C");
  17.  
  18. $x = array($a, $b, $c);
  19. $y = array($b);
  20. $z = array_diff($x, $y); # THIS doesn't work! -> Object of class X could not be converted to string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement