This question already has an answer here:
I got two arrays that I would like to combine based on "client_id" key (using PHP function is preferable) :
[all_client] => Array
(
[0] => Array
(
[client_id] => 1
[client_name] => Thomas Berg
[client_phone] => 12313123
[client_email] => aaaa@aaa.com
)
[1] => Array
(
[client_id] => 2
[client_name] => John Doe
[client_phone] => 4231241
[client_email] => asdas@asdas.com
)
)
[all_client_document] => Array
(
[0] => Array
(
[client_document_id] => 3
[client_document_number] => BX100
[client_document_type] => passport
[client_document_issued_date] => 2018-10-17
[client_document_expired_date] => 2018-12-02
[client_id] => 1
)
[1] => Array
(
[client_document_id] => 4
[client_document_number] => DJ200
[client_document_type] => passport
[client_document_issued_date] => 2018-10-15
[client_document_expired_date] => 2018-11-23
[client_id] => 2
)
)
)
How to merge these two array? Any PHP function to achieve this without foreach looping? I would hope to see the result as below :
[new_result] => Array
(
[0] => Array
(
[client_id] => 1
[client_name] => Thomas Berg
[client_phone] => 12313123
[client_email] => aaaa@aaa.com
[client_document_id] => 3
[client_document_number] => BX100
[client_document_type] => passport
[client_document_issued_date] => 2018-10-17
[client_document_expired_date] => 2018-12-02
)
[1] => Array
(
[client_id] => 2
[client_name] => John Doe
[client_phone] => 4231241
[client_email] => asdas@asdas.com
[client_document_id] => 4
[client_document_number] => DJ200
[client_document_type] => passport
[client_document_issued_date] => 2018-10-15
[client_document_expired_date] => 2018-11-23
)
)
How can I achieve this? Any help is much appreciated. Thanks in advanced before!
</div>