我有此數組:PHP - 排序上的其他指數的值的基礎上(存儲在另一個小陣列)陣列
Array
(
[0] => stdClass Object
(
[question_id] => 44
[question_name] => how to call javascript function in php
[question_type] => Single choice
[ttype_id] => 1
[marks] => 1
[pool_id] => 4
[deleted] => 0
[deleted_by] => 0
)
[1] => stdClass Object
(
[question_id] => 42
[question_name] => how to call recursive function
[question_type] => Single choice
[ttype_id] => 1
[marks] => 1
[pool_id] => 4
[deleted] => 0
[deleted_by] => 0
)
[2] => stdClass Object
(
[question_id] => 5
[question_name] => What is the correct way to end a PHP statement?
[question_type] => Single choice
[ttype_id] => 1
[marks] => 10
[pool_id] => 2
[deleted] => 0
[deleted_by] => 0
)
[3] => stdClass Object
(
[question_id] => 32
[question_name] => Who invented Copy, Paste?
[question_type] => Multiple choice
[ttype_id] => 1
[marks] => 5
[pool_id] => 1
[deleted] => 0
[deleted_by] => 1
)
[4] => stdClass Object
(
[question_id] => 32
[question_name] => Who invented Copy, Paste?
[question_type] => Multiple choice
[ttype_id] => 1
[marks] => 5
[pool_id] => 1
[deleted] => 0
[deleted_by] => 1
)
[5] => stdClass Object
(
[question_id] => 42
[question_name] => how to call recursive function
[question_type] => Single choice
[ttype_id] => 1
[marks] => 1
[pool_id] => 4
[deleted] => 0
[deleted_by] => 0
)
)
我需要通過存儲在另一個數組作爲pool_id
序列重新安排它:
$pool_order = array(1,2,3,4,5);
以便按此順序重新排列此數組。任何幫助?
我想這種安排:
Array
(
[0] => stdClass Object
(
[question_id] => 32
[question_name] => Who invented Copy, Paste?
[question_type] => Multiple choice
[ttype_id] => 1
[marks] => 5
[pool_id] => 1
[deleted] => 0
[deleted_by] => 1
)
[1] => stdClass Object
(
[question_id] => 32
[question_name] => Who invented Copy, Paste?
[question_type] => Multiple choice
[ttype_id] => 1
[marks] => 5
[pool_id] => 1
[deleted] => 0
[deleted_by] => 1
)
[2] => stdClass Object
(
[question_id] => 5
[question_name] => What is the correct way to end a PHP statement?
[question_type] => Single choice
[ttype_id] => 1
[marks] => 10
[pool_id] => 2
[deleted] => 0
[deleted_by] => 0
)
[3] => stdClass Object
(
[question_id] => 44
[question_name] => how to call javascript function in php
[question_type] => Single choice
[ttype_id] => 1
[marks] => 1
[pool_id] => 4
[deleted] => 0
[deleted_by] => 0
)
[4] => stdClass Object
(
[question_id] => 42
[question_name] => how to call recursive function
[question_type] => Single choice
[ttype_id] => 1
[marks] => 1
[pool_id] => 4
[deleted] => 0
[deleted_by] => 0
)
[5] => stdClass Object
(
[question_id] => 42
[question_name] => how to call recursive function
[question_type] => Single choice
[ttype_id] => 1
[marks] => 1
[pool_id] => 4
[deleted] => 0
[deleted_by] => 0
)
)
你做了什麼@Ali? –
http://stackoverflow.com/questions/2699086/sort-multi-dimensional-array-by-value我認爲這是重複的 – user1767754
你想要一個自定義的訂單,或只是一個desc或asc命令? –