bbm.txt文件包含:
BBM, PHP, John Smith, 16/11/2016
12345678 56
34567822 67
12324654 98
你应该
File name: bbm.txt
Module code: BBM
Module Name: PHP
Tutor: John Smith
The award date: 16/11/2016
12345678: 56
34567822: 67
12324654: 98
我得到了
BBM PHP John Smith 16/11/2016
12345678 56
34567822 67
12324654 98
请,需要帮助。
function readLineByLine () {
if (file_exists('bbm.txt')){
$tmaFileToOpen = fopen("bbm.txt", "r"); // open our bbm.txt file
if ($tmaFileToOpen) { // true if no errors occured
while(!feof($tmaFileToOpen)) {
// variable $result will display data in line by line
$result = fgets($tmaFileToOpen, 1024);
$split = explode(',', $result);
echo '<p>' . $split[0] . $split[1] . $split[2] . $split[3] . '</p>';
}
} else { // if an error occured message will be displayed
echo '<p>There is an error openning file!</p>';
}
fclose($tmaFileToOpen); // Close our bbm.txt file
} else { // if file doesn't exist message will be displayed
echo '<p>File requested not found!</p>';
}
}
echo readLineByLine();
答案 0 :(得分:0)
以上评论是正确的:
'<p>Module Code:' . $split[0] .'<br>Module Name: '. $split[1] .'<br>Tutor'. $split[2] .'<br>The award date: '. $split[3] . '</p>';