嘿,基本上,我有一個數組:PHP清理置換陣列
array('a', 'b', 'c');
現在我運行它通過陣列排列的功能,其結果是:
Array
(
[0] => Array
(
[0] => C
)
[1] => Array
(
[0] => B
)
[2] => Array
(
[0] => B
[1] => C
)
[3] => Array
(
[0] => C
[1] => B
)
[4] => Array
(
[0] => A
)
[5] => Array
(
[0] => A
[1] => C
)
[6] => Array
(
[0] => C
[1] => A
)
[7] => Array
(
[0] => A
[1] => B
)
[8] => Array
(
[0] => B
[1] => A
)
[9] => Array
(
[0] => A
[1] => B
[2] => C
)
[10] => Array
(
[0] => A
[1] => C
[2] => B
)
[11] => Array
(
[0] => B
[1] => A
[2] => C
)
[12] => Array
(
[0] => B
[1] => C
[2] => A
)
[13] => Array
(
[0] => C
[1] => A
[2] => B
)
[14] => Array
(
[0] => C
[1] => B
[2] => A
)
)
現在的問題是,如何清潔該陣列向上,以便:
array (C, B)
is the same as
array (B, C)
並刪除所述第二陣列
我該怎麼做?
編輯...根據您的回答經過一番研究,這是我想出了:
array_walk($array, 'sort');
$array = array_unique($array);
sort($array); // not necessary
爲什麼你就不能更換組合功能置換功能? – philfreo 2009-12-07 18:35:40
因爲我沒有編寫排列函數,因爲算法讓我感到困惑:P – Ozzy 2009-12-07 18:38:02