PHP Comma Delimited Help

Associate
Joined
20 Aug 2003
Posts
2,446
Location
London
Hi, I'm stuck, I've been trying this for couple of hours now.

What I'm trying to do is read normal text file done in notepad and open it up with PHP and explode it.

So for example If the notepad file consisted of info about cars Make, Model, Price, Date, Viewed e.g (Nissan,SkyLineGTR,25000,2002,10)

I want to read it in PHP and put it into array.

I can open the file to display the list of cars by doing:
Code:
<?
$filename = "cars.txt";
$filepoint = fopen($filename, "r");
$cararray = file ($filename);
for ($mycount = 0; $mycount < count($cararray); $mycount++)
 {
  $aline = $cararray[$mycount];
  print $aline ." \n";
 }
fclose ($filepoint);
?>

But I need to put it into array and exploded so the car info is showen as

Nissan
SkyLine
25000
2002
10

so all the information is in different row.

I tried this placing the $carlist = explode(",", $cararray);

but didnt work

Edit: Oops made mistake
 
Last edited:
Back
Top Bottom