I have two arrays, $array_A
and $array_B
. I'd like to append the first value from $array_B
to the end of the first value of $array_A
and repeat this approach for all elements in both arrays.
$array_A = ['foo', 'bar', 'quuz'];
$array_B = ['baz', 'qux', 'corge'];
Expected output after squishing:
['foobaz', 'barqux', 'quuzcorge']
array_merge($array_A, $array_B)
simply appends array B onto array A, and array_combine($array_A, $array_B)
sets array A to be the key for array B, neither of which I want. array_map
seems pretty close to what I want, but seems to always add a space between the two, which I don't want.
It would be ideal for the lengths of each array it to be irrelevant (e.g. array A has five entries, array B has seven entries, extra entries are ignored/trimmed) but not required.