Ho la seguente matrice:tipi multipli in un array
Array
(
[0] => Array
(
[note] => test
[year] => 2011
[type] => football
)
[1] => Array
(
[note] => test1
[year] => 2010
[type] => basket
)
[2] => Array
(
[note] => test2
[year] => 2012
[type] => football
)
[3] => Array
(
[note] => test3
[year] => 2009
[type] => basket
)
[4] => Array
(
[note] => test4
[year] => 2010
[type] => football
)
)
E desidero ordinare primo secondo un'altra matrice per tipo:
Ad esempio: $sort = array('football','basket');
e poi da anno.
Come posso farlo?
Grazie.
output desiderato dovrebbe essere:
Array
(
[2] => Array
(
[note] => test2
[year] => 2012
[type] => football
)
[0] => Array
(
[note] => test
[year] => 2011
[type] => football
)
[4] => Array
(
[note] => test4
[year] => 2010
[type] => football
)
[1] => Array
(
[note] => test1
[year] => 2010
[type] => basket
)
[3] => Array
(
[note] => test3
[year] => 2009
[type] => basket
)
)
Non mi importa se ci Azzera i valori di indice.
Grazie.
Grazie amico sembra funzionare. Ma come posso includere anche l'array $ sortBy? – glarkou
@salamis Ho modificato la mia risposta per coprire anche questo. – lafor
Grazie compagno sembra funzionare come previsto. una domanda veloce Perché usiamo ancora '$ type, SORT_ASC' se stiamo ordinando da un altro array? – glarkou