3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php Class MyFile { private $filename; private $mimeType; public function __construct($filename, $mimeType) { $this->filename = $filename; $this->mimeType = $mimeType; } public function getFilename() { return $this->filename; } public function getMimeType() { return $this->mimeType; } } $array1[] = new MyFile("peter.jpg", "image/jpg"); $array1[] = new MyFile("peter.jpg", "image/png"); $array1[] = new MyFile("michal.jpg", "image/jpg"); $array2[] = new MyFile("johan.jpg", "image/jpg"); $array2[] = new MyFile("peter.jpg", "image/jpg"); $diffArray = array_udiff($array1, $array2, 'compareFiles'); function compareFiles($a, $b) { if ($a->getFilename() < $b->getFilename()) { return -1; } elseif ($a->getFilename() > $b->getFilename()) { return 1; } else { return 0; } } var_dump($diffArray);
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
array(1) { [2]=> object(MyFile)#3 (2) { ["filename":"MyFile":private]=> string(10) "michal.jpg" ["mimeType":"MyFile":private]=> string(9) "image/jpg" } }
Output for 5.0.0 - 5.2.17
array(1) { [2]=> object(MyFile)#3 (2) { ["filename:private"]=> string(10) "michal.jpg" ["mimeType:private"]=> string(9) "image/jpg" } }
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/53ntB on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/53ntB on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/53ntB on line 5
Process exited with code 255.