开发者

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

开发者 https://www.devze.com 2023-04-06 17:01 出处:网络
$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)));
$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

精彩评论

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