1
我的代碼有什麼問題?添加變量的PHP數組
Warning: Invalid argument supplied for foreach() on line 12)
<?php
$id = array("price" => "10");
$id['price'][1] = $id['price'];
$id['price'][3] = ($id['price'] * 3 * 0.97);
$id['price'][6] = ($id['price'] * 6 * 0.95);
$id['price'][3] = round($id['price'][3],2);
$id['price'][6] = round($id['price'][6],2);
foreach($id['price'] as $money) {
echo '<option value="'.$money.'">.'.$money.'$</option>'."\n";
}
?>
感謝您的幫助。 –
避免弱類型:'price => array(「10」)'→'price => array(10)'。 –