Forum Moderators: coopster
[PHP]
$designer_arr = array('prada', 'gucci', 'DKNY');
$item_arr = Array(
[prada] => Array('handbag', 'belt'),
[gucci] => Array('hat', 'belt')'
[DKNY] => Array('handbag','hat')
)
$available_arr[] = array($record['designer'],$record['item']);
PHP]
I want to display the contents of the $designer_arr and $item_arr in a table as below:
¦ prada ¦ gucci ¦ dkny ¦
-------------------------
¦ handbag ¦ hat ¦handbag
¦ belt ¦ belt ¦ hat
I then want to compare these results with the contents of the $available_arr. If whats in the results above matches whats in the $available_array I want to colour it green, if not, red. I have the below code which almost works but it brings out the results multiple times. Obviously this is because Im using a foreach to go through the $available_arr to compare against the results, but I dont know how else to compare the two arrays and just diplay one set of data.
[PHP]
foreach($designer_arr as $designer){
foreach ($item_arr[$designer] as $item){
if ($available_numrows != 0){
foreach ($available_arr as $available){
$available_desginer = $available[0];
$available_item = $available[1];
if (($designer == $available_desginer)&&($item == $available_item)){
$class="color:green";
} else {
$class="color:red";
}
$html .= "<span style=\"$class\">$item¦</span>";
}
}
}
}[/PHP]