Answer the question
In order to leave comments, you need to log in
How to order a PHP array?
Hello!
I can't figure out how to sort an array, by string?
I have an array like this:
array(1) {
["items"]=>
array(1) {
["nodes:item"]=>
array(34) {
[0]=>
array(2) {
["attribute:id"]=>
string(5) "80857"
["node:value"]=>
string(8) "Z3 (E36)"
}
[1]=>
array(2) {
["attribute:id"]=>
string(6) "125135"
["node:value"]=>
string(7) "1 (E81)"
}
[2]=>
array(2) {
["attribute:id"]=>
string(6) "125024"
["node:value"]=>
string(7) "1 (E87)"
}
[3]=>
array(2) {
["attribute:id"]=>
string(6) "125646"
["node:value"]=>
string(13) "1 Coupe (E82)"
}
Answer the question
In order to leave comments, you need to log in
You can use usort by passing a closure with the comparison you want.
It is not at all clear which string is being discussed from the question, but in general the task is solved in this way.
What means
order array, by string? Do you mean sorting by the node:value field?
Aaaaa ... Finally, some kind of stuffing ...)))
Functions for working with arrays
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question