开发者

I am using fgets() to read in a line in PHP. But i am getting a wierd result?

$size = intval(trim(fgets($fp,4)));
$triangle = range(1,$size);
for($j=0;$j<$size;$j=$j+1)
    $triangle[$j] = split(" ",trim(fgets($fp,400)));

Thi开发者_高级运维s code reads in the number of lines to read, then reads them one by one. Issue is, when first input line ends in space, it reads that space as a new line.


you can read full file content by file_get_contents.

<?php
$content= file_get_contents('myfile.txt');
echo $content;
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜