我有一個數組AllUsers
作爲PHP多維數組操作
Array AllUsers
(
[0] => Array
(
[0] => Array
(
[0] => Tim
[1] => [email protected]
)
[1] => Array
(
[0] => John
[1] => [email protected]
)
)
[1] => Array
(
[0] => Array
(
[0] => Mike
[1] => [email protected]
)
[1] => Array
(
[0] => Aron
[1] => [email protected]
)
)
)
我有另一個數組FilteredUsers
作爲
Array FilteredUsers
(
[0] => Array
(
[0] => John
[1] => [email protected]
)
[1] => Array
(
[0] => Mike
[1] => [email protected]
)
[2] => Array
(
[0] => Mike
[1] => [email protected]
)
)
現在我想是的FilteredUsers[]
每個元素添加AllUsers[]
這樣 -
FilteredUsers[0]
應該得到廣告DED到批量AllUsers[1]
因爲批AllUsers[0]
已經在它的元素名稱約翰陣列- 同樣
FilteredUsers[1]
應該被添加到批量AllUsers[0]
- 任何批(如
AllUsers[0]
,AllUsers[1]
)不能有超過3個元素。如果全部批次已滿,則將創建新批次,但FilteredUsers[]
中的每個元素都應該包含在某些批次中。
所以更新AllUsers
陣列應該是這樣的 -
Array AllUsers
(
[0] => Array
(
[0] => Array
(
[0] => Tim
[1] => [email protected]
)
[1] => Array
(
[0] => John
[1] => [email protected]
)
[2] => Array
(
[0] => Mike
[1] => [email protected]
)
)
[1] => Array
(
[0] => Array
(
[0] => Mike
[1] => [email protected]
)
[1] => Array
(
[0] => Aron
[1] => [email protected]
)
[2] => Array
(
[0] => John
[1] => [email protected]
)
)
[2] => Array
(
[0] => Array
(
[0] => Mike
[1] => [email protected]
)
)
)
只是好奇心,爲什麼你需要3批?你可以輕鬆地做一個'for $($ i = 0; $ i <= count($ AllUsers),$ i + = 3){} –