N
N
Newon20172017-04-29 09:46:55
PHP
Newon2017, 2017-04-29 09:46:55

How do one php array compare with another add the difference to the last one?

Hello! Please tell me how to implement in php. There is an array $a (contains multiple values) and an array $b (empty). Compare $a with $b and add the difference to $b, then iterate until the array $b is completely filled with all elements from $a. Tried array_diff(), but it compares by values, not by keys

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel, 2017-04-29
@Palych_tw

php.net/manual/en/ref.array.php
We see the array_diff_assoc function, try

M
Maxim Fedorov, 2017-04-29
@qonand

I think array_merge will suit you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question