請你檢查一下這段代碼,看看它爲什麼返回一個未定義的偏移量:以及它如何修復。爲什麼我的php下拉表單導致未定義的偏移量
options.php
<?php
$options = array();
$options["PC 1"] = array("year"=>"2000","colour"=>"blue");
$options["PC 2"] = array("year"=>"2003","colour"=>"pink");
$options["PC 3"] = array("year"=>"2006","colour"=>"orange");
?>
的index.php
<html>
<body>
<form name="input" action="test.php" method="post">
Device Name: <?php
include("options.php");
echo '<select name="option">';
foreach($options as $name => $values)
{ echo '<option value="' .$name .'">' .$name .'</option>';
}
echo '</select>';
?>
<input type="submit" value="Submit" />
</form>
</body>
</html>
test.php的
<?php
include("options.php");
$chosenValue = $_POST['option'];
list($year,$colour) = $options[$chosenValue]; ---- here is the error line
echo $year;
echo $colour;
?>
感謝
什麼是確切的錯誤?如第8行'注意:未定義偏移'偏移' – fin1te 2011-05-19 12:09:51
注意:未定義偏移量:1在C:\ wamp \ www \ wol \ test.php中對第4行 – Michael 2011-05-19 12:11:45
它對於偏移量0和1 – Michael 2011-05-19 12:18:00