I have a multi-dimensional array like this:
Array
(
[0] => Array
(
[id] => 1
[email_id] => ok@gmail.com
[password] => test
)
[1] => Array
(
[id] => 2
[email_id] => check@gmail.com
[password] => test
)
[2] => Array
(
[id] => 3
[email_id] => an@gmail.com
[password] => pass
)
)
In the above array, password
value is the same in two different rows. I need to merge the arrays which have duplicate values to get the following output:
Array
(
[0] => Array
(
[0] => Array
(
[id] => 1
[email_id] => ok@gmail.com
[password] => test
)
[1] => Array
(
[id] => 2
[email_id] => check@gmail.com
[password] => test
)
)
[1] => Array
(
[id] => 3
[email_id] => an@gmail.com
[password] => pass
)
)
How to do this? I've tried array_merge()
& foreach()
loops, but I can't get this output.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…