PHP
·
发表于 5年以前
·
阅读量:8297
±¾ÎÄʵÀý½²ÊoÁËphp¶ÁÈ¡ÎļþÄÚÈݵ½Êý×eµÄ½¨¡£ÖÏi¸ø´o¼Ò¹(C)´o¼Ò²Î¿¼¡£¾ßÌaÖÎoÈçÏ£º
phpÖпÉÒÔͨ¹ýfile()º¯Êý½«Îļþ¶ÁÈ¡µ½Êý×eÖУ¬Êý×eÖеÄÔªËؼ´ÎªÎļþµÄÿÐУ¬file()º¯Êýͨ¹ý"\n"°´ÐÐ*Ö¸iÎļþ±£´aeµ½Êý×e£¬ËuÒÔÊý×eÿ¸oÔªËض¼ÊÇÒÔ"\n"½a⣬ÎÒÃÇ¿ÉÒÔͨ¹ý rtrim()º¯Êý½«ÆaÈ¥³ý
<?php
$lines = file("/tmp/file.txt");
foreach ($lines as $line) {
$line = rtrim($line);
print("$line\n");
// more statements...
}
?>
Ï£Íu±¾ÎÄËuÊo¶Ô´o¼ÒµÄphp³ÌÐoÉe¼ÆÓÐËu°iÖu¡£