我有一个commments.txt 文件,每行都有一个名称、电子邮件和评论。到目前为止,我能够以这种格式打印评论,但是当我对文件进行排序然后尝试打印它时,它只打印 111,我不知道为什么。排序.php:
$file = file("comments.txt");
$sortedAZ = sort($file);
print_r($sortedAZ);
注释.txt 文件:
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
到目前为止,我只有这样打印:
Name: Sally Doe
Comment: This is a comment
Name: Charlie Lee
Comment: This is another comment
Name: Bob Smith
Comment: Hello world
我正在尝试按名字的字母顺序对文件进行排序,以便打印出如下内容:
Name: Bob Smith
Comment: Hello world
Name: Charlie Lee
Comment: This is another comment
Name: Sally Doe
Comment: This is a comment