Novice Ask the big God: my matrix The last value of each row is always output with the first value in the next row. How did it break? Jsl_mini.txt is a matrix:
2015/5/4 4857.00 4780.00 4480.46
2015/5/5 4692.00 4736.00 4298.71
$file = ' jsl_mini.txt ';
echo $file. '
';
$content = file_get_contents ($file);
$array = explode ("\ t", $content);
echo $array [0]. '
';
echo $array [1]. '
';
Echo $array [2]. '
';
Echo $array [3]. '
';
Echo $array [4]. '
';
Echo $array [5]. '
';
?>
The output is:
Jsl_mini.txt
2015/5/4
4857.00
4780.00
4480.46 2015/5/5
4692.00
4736.00
That's the red line, what's the difference between 4480.46 and 2015/5/5?
Reply to discussion (solution)
It is recommended to write
$file = ' Jsl_mini.txt '; $rows = File ($file, File_skip_empty_lines | File_ignore_new_lines), foreach ($rows as $content) { $array = explode ("\ t", $content); echo $array [0]. '
'; echo $array [1]. '
'; Echo $array [2]. '
'; Echo $array [3]. '
';}
File_skip_empty_lines Skip Blank Line
File_ignore_new_lines Remove line break
'; }}? >
2015/5/4
4857.00
4780.00
4480.46
2015/5/5
4692.00
4736.00
4298.71
It is recommended to write
$file = ' Jsl_mini.txt '; $rows = File ($file, File_skip_empty_lines | File_ignore_new_lines), foreach ($rows as $content) { $array = explode ("\ t", $content); echo $array [0]. '
'; echo $array [1]. '
'; Echo $array [2]. '
'; Echo $array [3]. '
';}
File_skip_empty_lines Skip Blank Line
File_ignore_new_lines Remove line break
Thank you!
'; }}? >
2015/5/4
4857.00
4780.00
4480.46
2015/5/5
4692.00
4736.00
4298.71
Thank you!