I want to make my category menu responsive to the projects displayed. The projects have multiple categories so multiple category-menu-links can be active. Whichever category the project belongs to is specified on an included php file in an multidimensional array…
e.g.
$allProjects = array(
'project1' => array('corporate'),
'project2' => array('corporate', 'print'),
'project3' => array('web')
);
Now I want to check for each category if it is a value of the array 'project1', 'project2', 'project3',… within the array $allProjects and if so echo 'active'.
So far I have…
<?php if (($_GET['cat'] == 'corporate')) {echo 'active';}; || if (isset ($_GET['project'])) {if in_array('corporate', $_GET['project']) {echo 'active';}; ?>
Does that make sense?
UPDATE:
What I need is to check in the multidimensional array at a specific key (2nd level array) if a value exists (3rd level array)
so I guess something like this…
$project = $_GET('project');
$category = $_GET('cat');
foreach ($allProjects as $project => $categories) {
if in_array($category, $project);
echo 'yes';
}
I use $project, variables defined above, as key but that doesn't work. It expects the parameters to be arrays. All I want is to use the name of the project (defined in $project) as a key for the in_array function and check for appearance of $category in the values.
Thanks for help