You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If flags is SORT_STRING, formerly array has been copied and non-unique elements have been removed (without packing the array afterwards), but now a new array is built by adding the unique elements. This can result in different numeric indexes.
What is an "the array packing"? I suppose it is the C term that means resizing an array to eliminate gaps or something similar.
How exactly does removing duplicates from an internal copy of an array without afterwards packing the array affect numeric indexes? Does the C language preserve the size of the internal array, preserve the maximum numeric index, or any other effect? And most importantly,—what should this tell a PHP programmer who is unfamiliar with the terms "the array packing"?
Due to the lack of information about the internally packing of the array in the sentence "This can result in different numeric indexes", it is unclear: a) what "this" indicates b) in which specific cases numeric indexes may differ (although, maybe this is an unimportant question, it just happens sometimes) c) and what exactly from what exactly may differ?
I propose to reformulate the note. At least according to the following formula:
If flags is SORT_STRING, formerly array has been copied and non-unique elements have been removed (without packing the array afterwards [AND WHAT?]), but now a new array is built by adding the unique elements. This [WHAT EXACTLY?] can result [IN WHICH CACES?] in different numeric indexes [BETWEEN WHAT AND WHAT].
I know that, prior to PHP 7.2.0, after the array_unique function filters an input array, the last internal numeric index of the array copy don't reset, and, after adding a new value in the filtered array, the next numeric index gets the next value after the 'last maximum used numeric index':
The note in the unique_array() page says:
(This sentense is mentioniong in Backward incompatible changes 7.1.x to 1.2.x page and Changelog too.)
The following questions arise:
I propose to reformulate the note. At least according to the following formula:
I know that, prior to PHP 7.2.0, after the
array_unique
function filters an input array, the last internal numeric index of the array copy don't reset, and, after adding a new value in the filtered array, the next numeric index gets the next value after the 'last maximum used numeric index':Output prior to PHP 7.2.0:
Output as of PHP 7.2.0:
Did the words "different numeric indexes" mean this difference?
The text was updated successfully, but these errors were encountered: