我想在创建变量名的一部分时使用一些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