2014-10-19 69 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);