If your reasoning is to do away with a hardcoded if statement you can separate function and data...
// Important stuff
// Change the order of bonus importance using this array
$bonus_precedence = array("item", "manufacturer", "category");
// Change the symbol for each item with this associative array
$bonus_markers = array(
"item" => "i",
"manufacturer" => "m",
"category" => "c"
);
// Magic beyond here
foreach($bonus_precedence as $bonus_type) {
// Get the next bonus type
$bonus = $db->f("{$bonus_type}_bonus");
// Was there a bonus
if($bonus > 0) {
// Output the bonus in full and break the loop
$bonus_marker = $bonus_markers[$bonus_type];
$bonus .= " ($bonus_marker)";
break;
}
}
If it doesn't matter that it is hardcoded, stick to the long if statement. You can comment it easily and it is easy to read and comment:
// Only one bonus type is allowed
// Item bonuses are the most important if there is
// an item bonus we ignore all other bonuses
if($db->f("item_bonus") > 0) {
$bonus = "{$db->f("item_bonus")} (i)";
// Manufacturer bonuses are the next most important
} elseif($db->f("manufacturer_bonus") > 0) {
$bonus = "{$db->f("manufacturer_bonus")} (m)";
// Category bonus is the fallback if there are no
// other bonuses
} elseif($db->f("category_bonus") > 0) {
$bonus = "{$db->f("category_bonus")} (c)";
}
Otherwise at least try to make it comprehensible:
// Only one bonus type is allowed
$bonus =
// Item bonuses are the most important if there is
// an item bonus we ignore all other bonuses
($db->f("item_bonus") > 0 ? "{$db->f("item_bonus")} (i)" :
// Manufacturer bonuses are the next most important
($db->f("manufacturer_bonus") > 0 ? "{$db->f("manufacturer_bonus")} (m)" :
// Category bonus is the fallback if there are no
// other bonuses
($db->f("category_bonus") > 0 ? "{$db->f("category_bonus")} (c)" : "0")
)
);