By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,251 Members | 2,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,251 IT Pros & Developers. It's quick & easy.

PHP - display from txt file with explode function

P: 37
PHP - display from txt file with explode function

hi, i am trying to display all data from a txt file with a function of explode but does not work.....

[PHP] <?
#reads a text file outputs it to screen
$filename = "cdlist.txt";
$filepointer = fopen($filename,"r"); // open for read
$cdArray = file ($filename);

for ($mycount = 0; $mycount < count($cdArray); $mycount++ )
{
$string = getvalue ($cdArray,1);
$aline = $cdArray [$mycount];
print "$aline $string \n";
}
fclose ($filepointer);

function getvalue ($text, $commaToLookFor)
{
$intoarray = explode(",",$text);
return $intoarray[ $commaToLookFor];
}

if (!($filepointer = fopen($filename,"r"))) { exit; }
?>

[/PHP]
Oct 23 '07 #1
Share this Question
Share on Google+
1 Reply


pbmods
Expert 5K+
P: 5,821
Heya, 848lu.

Are you looking for fgetcsv()?
Nov 11 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.