我需要帮助。我有一个包含数字的文件:
105 5001 5450 1548
5158 7875 8785 2404
5410 1548 0 0
现在应该从这个文件中读取,然后保存一行的数字,并将其分开(在数字之间有空格的地方),然后将其保存在Variable上。例如:第一行:
$o = 105 $s=5001 $j=5450 $m=1548
我希望我答对了你的问题。这可能有助于
<?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);