Re: RFC proposal for adding SORT_STRICT flag to array_unique()
| From: | Morgan | Date: | Sat, 25 Oct 2025 11:05:00 +0000 |
| Subject: | Re: RFC proposal for adding SORT_STRICT flag to array_unique() | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128963@lists.php.net to get a copy of this message | ||
On 2025-10-25 21:23, Rob Landers wrote:
Other than the bytes in memory and how they’re laid out, I fail to see how 100 is different from 100. They’re conceptually identical, and array_* functions generally behave by **value**, not by **identity**.In the case of objects, "value" and "identity" are the same thing; without a __toString() method that always produces different strings for different objects, array_unique() can't be used to deduplicate an array of objects - which I find myself wanting to do on a fairly regular basis.
$uniques = array_values(array_combine(array_map(spl_object_id(...), $source_array), $source_array));