Answer the question
In order to leave comments, you need to log in
How to sort a multidimensional array?
There is a multidimensional array that needs to be sorted by the title field for all (for example, two) keys:
[travertino-romano-design]
[travertino-romano]
Array
(
[travertino-romano-design] => Array
(
[0] => Array
(
[title] => Black
)
[1] => Array
(
[title] => Grey
)
[2] => Array
(
[title] => Red
)
[3] => Array
(
[title] => White
)
)
[travertino-romano] => Array
(
[0] => Array
(
[title] => Black
)
[1] => Array
(
[title] => Grey
)
)
)
Answer the question
In order to leave comments, you need to log in
I figured it out myself))
Through the cycle I had to do:
foreach ($product_color_samples as $key => $value) {
$title_col = array_column($product_color_samples[$key], 'title');
array_multisort($title_col, SORT_ASC, $product_color_samples[$key]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question