4

I have an array with some value like this:

[Organization_id] => Array ( [0] => 4 [1] => 4 [2] => 4 ) 

but i want some thing like this:

[Organization_id] => Array ( [0] => 4 ) 

Thanks in advance..

0

2 Answers 2

4

If you don't care about the key to value association possibly messing up, you can use this:

$array = array_unique($array); 
Sign up to request clarification or add additional context in comments.

Comments

4

Although array_unique was mentioned twice now, I feel the answers failed to point out that you have to use the function on the nested array and not the array itself, so here is a usage example

$array = array( 'Organization_id' => array(4,4,4) ); $array['Organization_id'] = array_unique( $array['Organization_id'] ); print_r($array); 

which will do what you want.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.