2

i need to merge an 2d array, if possible without any loops. Is there any way to use those 2 Arrays:

$array1 = array(
    0 => array('LABEL' => 'Label1'),
    1 => array('LABEL' => 'Label2'),
    2 => array('LABEL' => 'Label3'),
);

$array2 = array(
    0 => array('LABEL' => 'Label1'),
    1 => array('LABEL' => 'Label2'),
    2 => array('LABEL' => 'Label4'),
);

and get this result:

$result = array(
    0 => array('LABEL' => 'Label1'),
    1 => array('LABEL' => 'Label2'),
    2 => array('LABEL' => 'Label3'),
    3 => array('LABEL' => 'Label4'),
);
0

1 Answer 1

3
$result = array_merge($array1, $array2);

And if you want no double results in the array, you could use the multidimensional array save function from the PHP comments here: http://www.php.net/manual/de/function.array-unique.php#97285

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.