3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Role { public $id; public $name; public function __construct($id, $name) { $this->id = $id; $this->name = $name; } } $arr = []; $arr[] = new Role(1, "test"); $role = new Role(1, "test"); var_dump(in_array($role, $arr));

preferences:
43.73 ms | 402 KiB | 5 Q