I have a file called cofig.txt (not config.txt)it contains the following:
1 :: ftp.gizmo.com :: user1 :: password1
2 :: ftp.yahoo.com :: user2 :: password2
3 :: ftp.cooldude.com :: user3 :: password3
4 :: ftp.jixjax.com :: user4 :: password4
5 :: ftp.tops.com :: user5:: password5
I would like to grab each entry and break it up into the four groups per line (using the :: as seperators)
Here is the code:
$fp = fopen ("cofig.txt", "r");
$array = array();
while ( ! feof ($fp) )
{
$line = fgets ($fp, 1024);
array_push ($array, $line);
explode("::", $array);
foreach ($array as $tochop)
{
print "<br><br>";
$chopped = explode("::", $tochop);
$name = $chopped[0];
$ftp = $chopped[1];
$user = $chopped[2];
$pass = $chopped[3];
print "$name<br>";
print "$ftp<br>";
print "$user<br>";
print "$pass";
//at this point I would like to actually do something with these variables, I just added the print function for testing purposes//
}
}
Now it grabs it fine but then it spits out the lines from the file it does it like this (It does spit out all entries so thats not the problem, I want it output to the browser entries 1 2 3 4 5 and then stop cause there are only 5 lines in the cofig file):
1
1
2
1
2
3
1
2
3
4
1
2
3
4
5
1
2
3
4
5