Hey every one,
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. LIKE THIS:
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
PLEAAASEEE HELPPPPPPP ME WITH MY PROBLEM AM VERY NEW TO PROGRAMMING
php:
PHP Code:
<?
$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);
?>
the array has this content:
Array
(
[0] => Take That, Greatest Hits, 2007, 10.99, 35
[1] => 50cent, Am Back, 2005, 11.88, 70
[2] => Mike Jone, Never Sing Alone, 2007, 12.99, 30
[3] => Terry Gamble, Alone, 1987, 13.99, 40
[4] => Michael Jackson, Am Bad, 1990, 15.99, 60
)