Answer the question
In order to leave comments, you need to log in
How to sort an array in Yii2 using ArrayHelper?
There is an array.
$array = [
[
'name' => 'name1',
'status' => 1,
'year' => 21
],
[
'name' => 'name2',
'status' => 0,
],
[
'name' => 'name3',
'status' => 0,
],
[
'name' => 'name4',
'status' => 0,
'year' => 30
],
[
'name' => 'name5',
'status' => 0,
'year' => 25
],
]
$array = [
[
'name' => 'name1',
'status' => 1,
'year' => 21
],
[
'name' => 'name5',
'status' => 0,
'year' => 25
],
[
'name' => 'name4',
'status' => 0,
'year' => 30
],
[
'name' => 'name2',
'status' => 0,
],
[
'name' => 'name3',
'status' => 0,
],
]
$array = [
[
'name' => 'name1',
'status' => 1,
'year' => 21
],
[
'name' => 'name4',
'status' => 0,
'year' => 30
],
[
'name' => 'name5',
'status' => 0,
'year' => 25
],
[
'name' => 'name2',
'status' => 0,
],
[
'name' => 'name3',
'status' => 0,
],
]
Answer the question
In order to leave comments, you need to log in
https://github.com/yiisoft/yii2/blob/master/docs/g...
There is a method ArrayHelper::multisort();
Everything is in the documentation:
www.yiiframework.com/doc-2.0/yii-helpers-arrayhelp... Too lazy
to read?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question