I have a commments.txt file that has a name, email and a comment on each line. I am able to print the comments in this format so far but when I sort the file and then try to print it, it only prints 111 and I'm not sure why. sort.php:
$file = file("comments.txt");
$sortedAZ = sort($file);
print_r($sortedAZ);
comments.txt file:
Sally Doe sally@doe.com This is a comment
Charlie Lee charlie@lee.com This is another comment
Bob Smith bob@smith.com Hello world
So far I only have it printing like this:
Name: Sally Doe
Comment: This is a comment
Name: Charlie Lee
Comment: This is another comment
Name: Bob Smith
Comment: Hello world
I'm trying to sort the file in alphabetic order by the first name so that it would print out something like:
Name: Bob Smith
Comment: Hello world
Name: Charlie Lee
Comment: This is another comment
Name: Sally Doe
Comment: This is a comment