我正在尝试在 html 文件中获取 10 个数字的用户输入,该文件将存储到 php 文件的数组中。虽然当我尝试打印数组时,我得到的只是“数组”这个词,但知道为什么吗?
HTML 文件:
<!DOCTYPE HTML>
<html>
<head>
<meta charset= "utf-8">
</head>
<body>
Please enter 10 numbers that will be stored in an array:
<form action="practice3.php" method="post">
<input type="text" name="number1[]" placeholder="First number"><br />
<input type="text" name="number2[]" placeholder="Second number"><br />
<input type="text" name="number3[]" placeholder="Third number"><br />
<input type="text" name="number4[]" placeholder="Fourth number"><br />
<input type="text" name="number5[]" placeholder="Fifth number"><br />
<input type="text" name="number6[]" placeholder="Sixth number"><br />
<input type="text" name="number7[]" placeholder="Seventh number"><br />
<input type="text" name="number8[]" placeholder="Eighth number"><br />
<input type="text" name="number9[]" placeholder="Ninth number"><br />
<input type="text" name="number10[]" placeholder="Tenth number"><br />
<input type="submit" name="submit" value="Submit">
</form>
</body>
PHP 文件:
<?php
$number1 = $_POST['number1'];
$number2 = $_POST['number2'];
$number3 = $_POST['number3'];
$number4 = $_POST['number4'];
$number5 = $_POST['number5'];
$number6 = $_POST['number6'];
$number7 = $_POST['number7'];
$number8 = $_POST['number8'];
$number9 = $_POST['number9'];
$number10 = $_POST['number10'];
$myArray = Array($number1, $number2, $number3, $number4, $number5, $number6, $number7, $number8, $number9, $number10);
echo $myArray;
?>