How does in_array check if an object is in an array of objects?

后端 未结 2 1923
轻奢々
轻奢々 2020-12-17 16:33

Does in_array() do object comparison where it checks that all attributes are the same? What if $obj1 === $obj2, will it just do pointer comparison

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-17 17:04

    Objects are always references in PHP 5+ and can only be copied (thus creating a new object) by using clone.

    That means you should be able to use in_array().

提交回复
热议问题