我需要用PHP數組合並PHP - array_merge不考慮鍵
我需要值合併幫助,
,所以如果我在陣列1的值這樣
(room room) and in array values (room) , merge will look like this = (room room)
但是,如果我有
(room room book) and (book book) merged array values will look like this (room room book book)
因此可以說,合併的數組值將是每個元素的最大數量,房間例如,在所有陣列
幾個例子, (書)(書)(書)=(書) (室書書)(的書房)=(庫室書書) (室室) (書書書)=(房間房間書書書) (室)(室)(房間房間房間)=(房間房間房間)
我試圖操作者+,但隨後
(室房間)(書籍書)是(房間房間預訂書),那不好
我試過array_merge,但隨後
(室)(室)是(室),這是好的 但 (客房)(室)是(室室室),這是錯誤的
它不依賴於順序,和鍵不項重要的,它始終是數字([0] [1]等)
ARRAYS:
[0] => Array
(
[0] => room
[1] => room
)
[1] => Array
(
[0] => book
[1] => book
[2] => book
[3] => book
)
EXPECTED RESULT = array (room, room, book , book , book, book)
[0] => Array
(
[0] => room
[1] => room
)
[1] => Array
(
[0] => room
)
EXPECTED RESULT = array (room, room)
[0] => Array
(
[0] => room
)
[1] => Array
(
[0] => room
)
EXPECTED RESULT = array (room)
[0] => Array
(
[0] => room
[1] => room
[2] => book
)
[1] => Array
(
[0] => room
[1] => book
)
[2] => Array
(
[0] => room
[1] => room
[2] => room
)
EXPECTED RESULT = array (room , room ,room , book)
所以常是在所有陣列
非常感謝你們每個ellement的最大計數,例如書籍,
馬立克
您的數組表示法不易讀。你可以包含數組的'print_r()'輸出,所以我們更容易看到數組的內容? –
@AmalMurali,它被編輯:)謝謝 – user3411282