Connor McManus Connor McManus - 3 months ago 23
PHP Question

PHP Array Duplicate Value

I have an array like this:

Array
(
[0] => Array
(
[0] => Array
(
[Foo] => FooBar
)

)

[1] => Array
(
[0] => Array
(
[Foo] => BarFoo
)
)

[2] => Array
(
[0] => Array
(
[Foo] => FooFoo
)

)

[3] => Array
(
[0] => Array
(
[Foo] => FooFoo
)

)


)

I basically want to be able to look at [2] and [3] and be able to merge those two together since their values are the same. Basically I just don't want to double count. Is there a simple way of doing this while looping through?

Answer

You can try this

$unique_array = array_map("unserialize",
      array_unique(array_map("serialize", $your_array)));
Comments