explode is not working to split string
Posted
by pmms
on Stack Overflow
See other posts from Stack Overflow
or by pmms
Published on 2010-05-17T13:52:22Z
Indexed on
2010/05/17
14:00 UTC
Read the original article
Hit count: 240
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 ="\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);
Thanks & Regards pmms
© Stack Overflow or respective owner