我有一个PHP数组,看起来像这样:
Array{
[0] {
'id' => '0',
'title' => 'foo',
'address' => '123 Somewhere',
}
[1] {
'id' => '1',
'title' => 'bar',
'address' => '123 Nowhere',
}
[2] {
'id' => '2',
'title' => 'barfoo',
'address' => '123 Elsewhere',
}
[3] {
'id' => '3',
'title' => 'foobar',
'address' => '123 Whereabouts',
}
}
我希望您可以将其按嵌套数组中的“title”关键字进行排序,结果如下:
Array{
[1] {
'id' => '1',
'title' => 'bar',
'address' => '123 Nowhere',
}
[2] {
'id' => '2',
'title' => 'barfoo',
'address' => '123 Elsewhere',
}
[0] {
'id' => '0',
'title' => 'foo',
'address' => '123 Somewhere',
}
[3] {
'id' => '3',
'title' => 'foobar',
'address' => '123 Whereabouts',
}
}
由于我通过嵌套键“id”跟踪每个嵌套数组,因此第一级键值并不重要。
我尝试过使用ksort(),但没有成功。