S
S
SharkyFLY2011-12-14 16:29:09
PHP
SharkyFLY, 2011-12-14 16:29:09

Sorting multidimensional php array?

49571827.png
So it's not possible to sort the array of elements (root) by property value

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
shagguboy, 2011-12-14
@SharkyFLY

en.php.net/manual/en/function.array-multisort.php
array_multisort
(PHP 4, PHP 5)
array_multisort - Sorts multiple arrays or multidimensional arrays

G
Gesper, 2011-12-14
@Gesper

php.net/manual/en/function.usort.php
Write the desired cmp_function and sort as you please.

I
ikomixe, 2013-09-26
@ikomixe

You can use the standard php uasort function You
can read it here
php uasort
uasort($Array, function($first, $second) {
if ($first->p == $second->p) {
return 0;
}
return ($first->p < $second->p) ? 1 : -1;
});

S
sdevalex, 2011-12-14
@sdevalex

Most likely there is no ready-made solution for such sorting, it is too specific. Create a separate array with element ID and property value... sort this array.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question