我有一個多數組(目前有對象),我想基於特定的鍵/值重新排序。PHP/MySQL:從現有數組重新創建多維數組
Array
(
[0] => stdClass Object
(
[task_id] => 1
[task_title] => Title
[users_username] => John
)
[1] => stdClass Object
(
[task_id] => 2
[task_title] => Title
[users_username] => John
)
[2] => stdClass Object
(
[task_id] => 3
[task_title] => Title
[users_username] => Mike
)
)
我想重新排列它以通過user_name獲取多數組,所以我可以通過用戶名循環執行任務。
Array
(
[John] => Array
(
[0] => Array
(
[task_id] => 1
[title] => Title
)
[1] => Array
(
[task_id] => 2
[title] => Title
)
)
[Mike] => Array
(
[0] => Array
(
[task_id] => 3
[title] => Title
)
)
)
是否有可能我的陣列重建像上面的陣列?
謝謝,這很短,工作。不知道這是如此簡單:-) – suntrop 2012-01-08 12:25:09
不確定你是如何得到這個工作的,因爲它在PHP中是無效的語法。 – 2012-01-09 03:34:08