我想在創建變量名的一部分時使用一些mysql數據來引用已在其他地方聲明的另一個變量。基本上我怎樣才能讓$ damage_name成爲if語句布爾檢查的一部分?使用數組設置變量名稱
$conditions = array(
'bent_num' => 0,
'spine_torn' => 0,
'pages_torn' => 0,
'water_damage' => 0,
'pages_highlighted' => 0,
'pages_noted' => 0,
'taped' => 0,
'stained' => 0,
'mold' => 0,
'scratched' => 0
);
while ($row = mysql_fetch_assoc($res))
{
$damage_name = $conditions[$row['type']];
if (isset($conditions[$row['type']]) && $_SESSION[SELL_is_ . $damage_name . ]; == 'y')
{
$condition_score = $condition_score - $row['value'];
}
}
哦真棒感謝 – 2012-01-11 21:21:31