dsjfrkvn818747 2010-05-17 13:52
浏览 72

explode无法拆分字符串

we unable to split the string following code.please Help us.

 <?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 ="
";
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);
  • 写回答

3条回答 默认 最新

  • dougui1977 2010-05-17 13:55
    关注

    You're exploding on whitespace. Unless there is whitespace in the string your exploding then no, it won't work.

    Try using the code markup to make your code a little more readable in order to get better quality responses from people.

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?