PHP包含文本文件和格式 [英] PHP include text file and format

查看:99
本文介绍了PHP包含文本文件和格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的文本文件.文件名为kpop.txt-我要做的是在网页中包含文件的内容.我正在使用php进行包含(页眉/页脚内容).

I have a simple text file. The file name is kpop.txt - What I want to do is include the contents of the file in a webpage. I am using php for includes (header / footer stuff).

我希望kpop.txt文件的内容保持与当前格式相似的格式.我唯一想做的就是增加字体大小.

I would like the contents of the kpop.txt file to remain formatted similar to it's current form. The only real difference that I would like to make is to increase the font size.

我当前正在使用

<?php
include("kpop.txt");
?>

我也尝试过

<pre>
<font size ="12">
<?php
include("kpop.txt");
?>
</font>
</pre>

我想看到的是这样的文字,只是带有较大的字体.

What I want to see is my text like this but simply with a larger font.

FTUS43 KGGW 271140
TAF
KP01 271140Z 2706/2806 08010KT P6SM SCT140
     FM271500 12011KT P6SM SCT110
     FM271900 14011KT P6SM BKN120
     FM280000 14008KT P6SM VCSH BKN100
     FM280300 13006KT P6SM VCSH SCT100
      AMD NOT SKED. UNFL=

TAF
KM75 271140Z 2706/2806 07008KT P6SM SCT110
     FM271500 11008KT P6SM FEW150
      AMD NOT SKED. UNFL=

另一个无效的解决方案是

Another solution that did not work is

    <?php

    myfilename = "kpop.txt";
    $TAF = file_get_contents(myfilename);
    $TAFlines = explode("\n", $TAF);

    //echo $TAF;
    echo $TAFlines;


}
?>

我也尝试过使用file_get_contents函数和explode函数,但似乎无法正常工作.任何帮助,我们将不胜感激.

I have also tried using the file_get_contents function along with an explode function but cannot seem to get that to work properly. Any help is greatly appreciated.

推荐答案

这就是我想出的.

<pre>
<?php

//Read in the file and increase the font 200%
$TAF = file_get_contents("kpop.txt");
echo "<div style='font-size:200%'><p>$TAF</p></div>";

?>
</pre>

它可能并不漂亮,但是可以工作.谢谢大家的帮助.

It may not be pretty but it works. Thank you all for your help.

这篇关于PHP包含文本文件和格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆