I got this problem with my code and would love it if any one could help with this probelm.
Am creating a program that reconises commas in text file (comma delimited code) and i want to implement the same function and loop. This
program should get the file, store it ina array then enter a loop that jumps in to the
function.
here is the txt file:
Take That, Greatest Hits, 2007, 10.99, 35
50cent, Am Back, 2005, 11.88, 70
Mike Jone, Never Sing Alone, 2007, 12.99, 30
Terry Gamble, Alone, 1987, 13.99, 40
Michael Jackson, Am Bad, 1990, 15.99, 60
The problem is the code below displays this:
Take That
Am Back
2007
13.99
60
BUT IT SHOULD PRINT ALL THE INFORMATION IN THE TXT FILE ONE AFTER THE FILE UNDER EACH
OTHER.
PLEAAASEEE HELPPPPPPP ME WITH MY PROBLEM AM VERY NEW TO PROGRAMMING
Code: Select all
<?
$filename = "filename.txt";
$filepointer = fopen($filename, "r");
$myarray = file ($filename);
for ($mycount = 0; $mycount < count ($myarray);$mycount++)
{
$aline = $myarray[$mycount];
$cd = getvalue($myarray[0], $mycount);
print "$cd" . "<br> \n";
}
function getvalue($file, $mycount)
{
$intoarray = explode (",", $file);
return $intoarray[$mycount];
}
fclose($filepointer);
?>