array_multisort($name,SORT_ASC,$age,SORT_DESC,$arr);This sentence is only valid for $name, but not for $age. So is it redundant to write $age?
Rain2018-07-18 12:42:51
After repeated debugging, we found that the $arr parameter of the array_multisort function is equivalent to appending the sorting changes made by the previous parameters to the
$arr ontology array, because the array_multisort function is called by value. The previous The sorting operation is the operation of the copy. The $arr parameter is equivalent to a
reassignment, which ensures the change of the ontology. But it cannot be completely regarded as a reassignment operation, because when the $arr parameter is changed to a new array $newArr parameter, the system will report an error. It can be seen that the role of the $arr parameter is similar to that of reassignment. Assignment operation but not.
Rain2018-07-18 12:27:37
will not appear redundant. The $name array and the $age array are separated from the two-dimensional array $arr array.
If you only use the sort() or asort() function to sort the $name array, only the elements of the $name array will be changed.
Sequence (the $name array is only a copy of a part of the $arr array, and changes in the copy will not cause changes to the ontology),
will not cause changes to the original two-dimensional array $arr. So if you are sorting multi-dimensional arrays, you should use the array_multisort function.
array_multisort() can be used to sort multiple arrays at once, or to sort multi-dimensional arrays according to a certain dimension or multiple dimensions. This example is the second way to sort
multi-dimensional arrays based on a certain dimension. array_multisort($name, SORT_ASC,$age,SORT_DESC,$arr) implements the sorting of the name attribute column, and the age attribute column
will be sorted accordingly. In this way, it can actually be written as array_multisort($name, SORT_ASC,$age,$arr). The result of removing SORT_DESC will not change, because it has no effect
. By default, it only works on the first array. The second one will change according to the first one (of course this is an operation for multi-dimensional arrays).
CCIE2017-09-19 14:07:58
array_multisort($name,SORT_ASC,$age,SORT_DESC,$arr); This sentence is only valid for $name, but not for $age. So is it redundant to write $age?
CCIE2017-09-19 14:07:46
array_multisort($name,SORT_ASC,$age,SORT_DESC,$arr); This sentence is only valid for $name, but not for $age. So is it redundant to write $age?
CCIE2017-09-19 14:07:32
array_multisort($name,SORT_ASC,$age,SORT_DESC,$arr); This sentence is only valid for $name, but not for $age. So is it redundant to write $age?
CCIE2017-09-19 14:07:17
array_multisort($name,SORT_ASC,$age,SORT_DESC,$arr); This sentence is only valid for $name, but not for $age. So is it redundant to write $age?
CCIE2017-09-19 14:07:03
array_multisort($name,SORT_ASC,$age,SORT_DESC,$arr); This sentence is only valid for $name, but not for $age. So is it redundant to write $age?
CCIE2017-09-19 14:06:53
array_multisort($name,SORT_ASC,$age,SORT_DESC,$arr); This sentence is only valid for $name, but not for $age. So is it redundant to write $age?
CCIE2017-09-19 14:06:37
array_multisort($name,SORT_ASC,$age,SORT_DESC,$arr); This sentence is only valid for $name, but not for $age. So is it redundant to write $age?