我有这个数组:
[0] => Array
(
[userid] => 208
[username] => sara
[email] => sara@sara.com
)
[1] => Array
(
[userid] => 4
[username] => jack
[email] => jack@jack.com
)
[2] => Array
(
[userid] => 303
[username] => michael
[email] => michael@michael.com
)
[3] => Array
(
[userid] => 208
[username] => joe
[email] => joe@joe.com
)
[4] => Array
(
[userid] => 208
[username] => david
[email] => david@david.com
)
我想要这个结果:
[0] => Array
(
[userid] => 208
[username1] => sara
[username2] => joe
[username3] => david
[email1] => sara@sara.com
[email2] => joe@joe.com
[email3] => david@david.com
)
[1] => Array
(
[userid] => 4
[username1] => jack
[email1] => jack@jack.com
)
[2] => Array
(
[userid] => 303
[username1] => michael
[email1] => michael@michael.com
)
我正在尝试将 array_combine、array_merge 甚至 array_unique 与几个 foreach 加 $n++; 循环没有成功。更准确地说,我成功了,但改变了数组的整个结构。