0

我需要帮助。我有一个包含数字的文件:

105 5001 5450 1548

5158 7875 8785 2404

5410 1548 0 0

现在应该从这个文件中读取,然后保存一行的数字并将其分开(数字之间有空格。)并将其保存在变量上。例如:拳头线:

$o = 105    $s=5001    $j=5450    $m=1548 
4

1 回答 1

0

我希望你的问题是正确的。这可能会有所帮助

<?php
$handle = fopen("inputfile.txt", "r");
if ($handle) {
    while (($line = fgets($handle)) !== false) {
        list($o, $s, $j, $m) = explode(' ', $line);
        // do soethings with your variables $o, $s, $j, $m
    }
} else {
    // error opening the file.
}
fclose($handle);
于 2014-10-19T16:19:29.517 回答