我需要在輸出中的一組文本文件中分隔換行符。目前,我們可以分塊顯示網頁上文件夾中的所有文本文件,但是文本數據組合在文本塊中,我想學習如何識別換行符并將顯示的內容向下移動一兩行創建一個易于閱讀的分隔符。我沒有嘗試任何東西,因為我對如何識別換行符并顯示它感到困惑。$directory = "feeds/";$dir = opendir($directory);while (($file = readdir($dir)) !== false) { $filename = $directory . $file; $type = filetype($filename); if ($type == 'file') { $contents = file_get_contents($filename); $items = explode('/n', $contents); echo '<table width="100%" border="1" cellpadding="4" bgcolor="#fff">'; foreach ($items as $item) { echo "<tr><td>$item</td></tr>\n"; } echo '</table>'; }}closedir($dir);?>```Output at the moment is this@mpgradio - Mark Rogers - Imagining playing on MPG Radios.. Innovative Music Mix - http://www.mpgradio.ca/radio/imm/ Your music could be included in our rotations, just reach out to us. @lacroix_gen - Gen Lacroix - l’extase de l’oubli playing on MPG Radios.. Reflection Town - http://www.mpgradio.ca/radio/rt/ Where you have the opportunity to listen to unsigned independent artists.Expected output is would be something like.@mpgradio - Mark Rogers - Imagining playing on MPG Radios.. Innovative Music Mix - http://www.mpgradio.ca/radio/imm/ Your music could be included in our rotations, just reach out to us.@lacroix_gen - Gen Lacroix - l’extase de l’oubli playing on MPG Radios.. Reflection Town - http://www.mpgradio.ca/radio/rt/ Where you have the opportunity to listen to unsigned independent artists.
從文本文件目錄中讀取文件內容時,文本文件中的單獨換行符(新行向下)
慕工程0101907
2021-07-05 10:55:15