我們無法拆分下面的code.please字符串幫助我們。explode不工作,拆分字符串
<?php
$i=0;
$myFile = "testFile.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = "no\t";
fwrite($fh, $stringData);
$stringData = "username \t";
fwrite($fh, $stringData);
$stringData ="password \t";
fwrite ($fh,$stringData);
$newline ="\r\n";
fwrite ($fh,$newline);
$stringData1 = "1\t";
fwrite($fh, $stringData1);
$stringData1 = "srinivas \t";
fwrite($fh, $stringData1);
$stringData1 ="malayappa \t";
fwrite ($fh,$stringData1);
fclose($fh);
?>
$fh = fopen("testFile.txt", "r");
$
while (!feof($fh)) {
$line = fgets($fh);
echo $line;
}
fclose($fh);
$Beatles = array('pmm','malayappa','sreenivas','PHP');
for($i=0;$i<count($Beatles);$i++)
{
if($i==2)
{
echo $Beatles[$i-1];
echo $Beatles[$i-2];
}
}
$pass_ar=array();
$fh = fopen("testFile.txt", "r");
while (!feof($fh)) {
$line = fgets($fh);
echo $line;
$t1=explode(" ",$line);
print_r($t1);
array_push($pass_ar,t1);
}
fclose($fh);
固定您的格式(至少有一點)。請用樣本字符串和爆炸創建一個測試用例,這可能有助於我們幫助您。 – dbemerlin 2010-05-17 13:55:55
請指定什麼不工作,以及數據看起來像你想分裂。 – 2010-05-17 13:56:00
用print_r($ t1)得到的輸出是什麼;'? – Sarfraz 2010-05-17 13:56:05