I am trying to check if I have the $subCat value in the array then don't add it. I should end up with one of each $subCat but when I dump $details I am still getting the full array. Why is this?
foreach ($detailsFunction as $main)
{
$mainlisting = $main['listingId'];
$mainCat = strtolower($main['mainCat']);
$subCatO = strtolower($main['subCat']);
$subCat = str_replace(" ", "-", $subCatO);
if(isset($subCat) && $subCat == $subCat)
{
$details[] = array('url' => base_url().'listings/'.$mainCat.'/'.$subCat,
'mainCat' => $main['mainCat'],
'subCat' => $main['subCat']
);
}
}
$subCatexists? Right now you're just checking if the variable is set, and if it equals itself (which will always be true)