So I have this simple code for taking each product, finding the type, and making that a category to show up in my site.
public function get_categories()
{
$products = $this->get_products();
$categories = array();
$i = '-1';
foreach($products as $product)
{
$name = ucfirst(strtolower($this->ci->inflect->pluralize($product['type'])));
if(!in_array($name, $categories))
{
$i++;
$categories[$i] = array(
'name' => $name,
'type' => strtolower($product['type']),
);
}
}
return $categories;
}
Now, it was working just fine until I needed to pass the type
along with the name
so now I'm making a multi-dimensional array.
Now obviously the name
is never in array categories
because its inside another array in that one.
How can I detect if the name
already exists in the arrays inside the array categories
?