是否有任何關於知道我怎麼可以轉換這個組織的數組與PHP
$events = array(
array("type" => "off-site", "title" => "aaa", "nid" => "11"),
array("type" => "off-site", "title" => "bbb", "nid" => "22"),
array("type" => "installation", "title" => "ccc", "nid" => "33"),
array("type" => "opening", "title" => "ddd", "nid" => "44"),
array("type" => "opening", "title" => "eee", "nid" => "55"),
array("type" => "opening", "title" => "fff", "nid" => "66")
);
這個
$events_processed = array(
"off-site" => array(
array(
"title" => "aaa",
"nid" => "11"
),
array(
"title" => "bbb",
"nid" => "22"
)
),
"installation" => array(
array(
"title" => "ccc",
"nid" => "33"
)
),
"opening" => array(
array(
"title" => "ddd",
"nid" => "44"
),
array(
"title" => "eee",
"nid" => "55"
),
array(
"title" => "fff",
"nid" => "66"
)
)
);
使用PHP?
我已經嘗試過從不同的帖子應用不同的方法,但沒有成功。 我需要的數組被嵌套這樣我就可以重新排序的「類型」的數組.Hi
你嘗試使用[array_walk()](http://php.net/manual/en/function.array-walk.php)?或只是循環遍歷數組可能會更容易 – ianbarker 2012-03-20 17:25:17