tags:

views:

79

answers:

2

Hello,

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..

+3  A: 

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

$array = array_unique($array);
Tatu Ulmanen
+2  A: 

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.

Gordon