I have a PHP array that looks like this:
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', } }
and I want to sort it by the "title" key in nested arrays to look like this:
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', } }
The values โโof the first level key do not matter, since I track each nested array through the nested key "id".
I played with ksort (), but without success.
melat0nin
source share