0

I have two arrays. I'd like to merge them into one, but remove the redundant values. How can I do this?

1 Answer 1

3

Use array_unique function .

Example

<?php $input = array("a" => "green", "red", "b" => "green", "blue", "red"); $result = array_unique($input); print_r($result); ?> 

Output:

Array ( [a] => green [0] => red [1] => blue ) 
Sign up to request clarification or add additional context in comments.

1 Comment

but this is only for single dimensional array... if multi dimensional array what we do..

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.