我知道这里一般不接受帮助做作业,但我已经被困了一个多星期了,所以我会非常感谢任何帮助。概念上似乎很简单,但我无法从分解文件到将该信息放入数组中。
目标是有一些东西来比较从表单输入的文本。例如,如果名称 Bob 被输入到名称字段中,那么将有一种方法可以查看 Bob 的名称是否已经在列表中。
这是我最近的尝试:
<?php
if(isset($_POST['sname'],$_POST['snumber'],$_POST['courseselect']))
{
//Has to be submitted first
$studentname = $_POST['sname'];
$studentnumber = $_POST['snumber'];
$course = $_POST['courseselect'];
if(empty($studentname) || empty($studentnumber))
{
//make sure all fields are filled in
echo "All fields must be filled in";//for if they aren't filled in
}
else
{
//if they are filled in
$studentfile = "students";
$SF = fopen($studentfile, 'r') or die("$studentfile cannot be opened for reading");
while($studentlist = fgets($SF))
{
list ($stoodname, $stoodnumber) = explode('::', $studentlist);
$testarray[] = array('$stoodname');
echo $testarray;
}
}
//end of if/else
}//end of "has to be submitted"
?>
我觉得我只是错过了一些明显的东西:(