I have been attempting to write a website that processes names of people and reads them back in a list, so I can do other things with them later. I need them to be alphabetized, and show up with each person on their own line. Kind of like this:
[1] Doe--John
[2] Washington--George
[3] Zekeman--William
I have created a php script that uses an array to sort the names; it is in the file sort.php. I have created a file for the people, called students.html. These names were fed in from a form.
To display the name on the webpage, I created a simple php include function.
Here is my coding:
Sort.php
<?php
$filename = "students.html"
$names = array file( string $filename );
sort($names);
foreach ($names as $key => $val) {
echo "[" . $key . "] " . $val . "\n";
}
?>
Students.html
"Washington--George",
"Zekeman--William",
"Doe--John",
Webpage
<?php include 'sort.php';?>
Everything works perfectly, except the webpage displays this error:
Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/www/the/path/to/my/directory/sort.php on line 3
I have played with it and I cannot figure out how to fix the error. Any assistance would be greatly appreciated!
Note: I apologize if this makes no sense. I am brand new to this.