I have a JSON array converted to a PHP associative array. I'm attempting to loop through this associative array, and where the key matches a value held in a separate array ($filter
), I want to echo the key
and value
from my associative array.
$filter = array("test1", "test");
foreach ($central as $key => $value) {
$key = str_replace("_", " ", $key);
if(in_array('$filter', $key)){
echo "<ul>".ucwords($key).':' .' '. $value."</ul>";
}
else {
continue;
}
}
So to recap, if the $key
of my $central
associative array is equal to a value in my $filter
array I want to echo out the values. Else go to the next item in the loop. This code does not work however,
syntax error, unexpected '=>'