I have an array that contains multiple transactions, with multiple transactions being from the same email address.
Some of these transactions have a value in the client
key. Others don't.
I want to copy the filled client
key in all matching arrays with the same email_address
key, in order to always have data in the client
key.
Example of my array:
Array
(
[1] => Array
(
[client] => John John
[email_address] => john@john.com
)
[3] => Array
(
[client] => Kevin Kevin
[email_address] => kevin@kevin.com
)
[5] => Array
(
[client] =>
[email_address] => john@john.com
)
)
What I want to achieve is to make sure that Array [5]
has the same value in the client
key as Array [1]
because it's the same client (based on email_address
key).
Example of the resulted array:
Array
(
[1] => Array
(
[client] => John John
[email_address] => john@john.com
)
[3] => Array
(
[client] => Kevin Kevin
[email_address] => kevin@kevin.com
)
[5] => Array
(
[client] => John John
[email_address] => john@john.com
)
)
How can I go through the array to make sure that matching arrays (based on email_address
key) always have the same client
key?