I know you'll probably think this is a dupe question, and that may be the case but nothing I found seems to actually sort my array. I have built my array and the output looks something like this:
Array => [
[1] => [
[1] => [
'foo' => 'bar',
'foobar' => 'foo'
],
[2] => [
'foo' => 'bar',
'foobar' => 'foo'
],
[3] => [
'foo' => 'bar',
'foobar' => 'foo'
],
[4] => [
'foo' => 'foo',
'foobar' => 'bar'
],
[5] => [
'foo' => 'foo',
'foobar' => 'bar'
],
[6] => [
'foo' => 'foo',
'foobar' => 'bar'
]
]
]
I tried getting rid of the dupe subarrays using these two methods:
array_unique($data, SORT_REGULAR);
but nothing changed.
I also tried using:
$data = array_map(
'unserialize',
array_unique(array_map('serialize', $data))
);
But that does nothing either. I've also tried foreach'ing my $data array and adding a to a new array like so:
$newData = [];
foreach ($data as $key => $item)
{
$newData[$key] = array_map(
'unserialize', array_unique(array_map('serialize', $item))
);
}
but that only returned one sub array per key. What am I doing wrong?