2

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?

2
  • Is this structure always the same? [0] => Array ( [0] => Array ( [Foo] => FooBar ) ) Commented Aug 17, 2016 at 18:53
  • Yes, obviously with different values, but yes same structure! Commented Aug 17, 2016 at 18:56

1 Answer 1

2

You can try this

$unique_array = array_map("unserialize",
      array_unique(array_map("serialize", $your_array)));
Sign up to request clarification or add additional context in comments.

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.