I have an array I'm pulling from a MySQL db and I need to reformat it into another array without any duplicates on a specific key.
Original array:
Array // $categories array
(
[0] => Array
(
[name] => Body & Bath Products
[keyword] => body-and-bath-products
)
[more ...]
)
New array structure:
Array // $links array
(
[0] => Array
(
[keyword] => Body & Bath Products
[link] => ./Body-and-Bath-Products
[target] => _self
[tooltip] => 1
)
[more ...]
)
Looping through with PHP:
$links = array();
foreach ($categories as $cat):
if (in_array ($cat['name'], $links)):
continue;
else:
$links[] = array(
'keyword' => $cat['name'],
'link' => './' . $this->url->cap_keyword($cat['keyword']),
'target' => '_self',
'tooltip' => true
);
endif;
endforeach;
But this isn't working, still getting all 534 entries in my $links array.
I know it's something simple but I'm just missing it somehow ...
$links['keyword']?