Created
July 7, 2016 15:32
-
-
Save TorbenKoehn/53ab27b0e0157a0332b52dd8c4ba0500 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyCollection | |
{ | |
//Iterator/ArrayAccess/Countable stuff... | |
public overload -(array $other) | |
{ | |
return new self(array_diff($this->items, $other)); | |
} | |
} | |
$col = new MyCollection(['a' => 1, 'b' => 2, 'c' => 3]); | |
$diff = $col - array_flip(['a', 'c']); | |
var_dump($col); // MyCollection(['b' => 2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment