我已經得到了默認每一個數組:PHP重新排序陣列
array(1=>1,2 =>2, 3=>3, 4=>4, 5=>5, 6=>6, 7=>7, 8=>8, 9=>9)
現在的操作是有可能改變,例如號碼爲:
array(1=>1, 2=>1, 3=>3, 4=>1, 5=>1, 6=>6, 7=>7, 8=>8, 9=>9)
--> changed the value of key 1, 2, 4 and 5
這個我需要以下結果後
array(1=>1, 2=1, 3=>2, 4=>1, 5=>1, 6=>3, 7=>4, 8=>5, 9=>6 )
--> changed the value of key 3, 6, 7, 8, 9 in the right order that no number is missing like the operation has done above.
它的網格3x3。位置1是1,位置2是2,依此類推。現在數據庫可以設置位置1,2,4,5是相同的並且與1相同。因此,數據庫發送:1,1,3,1,1,6,7,8,9。現在來自地點的字段3是3,但應該是從2開始的字段。此外6的字段現在必須是字段3,依此類推。
注意:該操作可以更改數組中的每個值。例如 鍵值4,5,7,8
我該怎麼做?
[你有什麼嘗試?](http://www.whathaveyoutried.com/)請參閱[問問建議](http://stackoverflow.com/questions/ask-advice)。 – 2013-03-08 13:49:24
[在這裏你可以找到最簡單的PHP問題,PHP.net頁面的答案](http://php.net/manual/en/language.types.array.php)。另外,爲什麼你不穀歌「陣列PHP」? – 2013-03-08 13:52:25
你給我們提一個智商測試的問題嗎? :D喜歡找到系列中的下一個元素? :) – 2013-03-08 13:53:35