2014-10-19 67 views
0

我需要帮助。 我有一个文件,其中包括数字:从文件中读取并使用爆炸功能

105 5001 5450 1548 

5158 7875 8785 2404 

5410 1548 0 0 

现在应该从这个文件中读取然后保存行的数量和间隔是(它具有数字之间的空间),并将其保存在变。 例如:握拳路线:

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

回答

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);