【发布时间】:2010-05-17 13:52:22
【问题描述】:
我们无法拆分代码后面的字符串。请帮助我们。
<?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);
【问题讨论】:
-
修正了你的格式(至少一点点)。请创建一个带有示例字符串的测试用例和您的分解,这可能有助于我们为您提供帮助。
-
请具体说明什么不起作用以及您尝试拆分的数据是什么样的。
-
print_r($t1);的输出是什么? -
请以正确的方式格式化代码,以便任何人都可以阅读。另请澄清您的问题,提供例如你想得到的输出/结果和你当前得到的输出/结果。