...

View Full Version : PHP Explode



ItsMe
06-23-2005, 07:04 PM
I have this code:

<?php
$handle = fopen("info.csv", "r");
$data = fgetcsv($handle, 1000, ";");
$data2 = explode(",", $data);
echo $data2[0]; // piece1
echo $data2[1]; // piece2
?> It gets a csv file and then what i want it to do is explode it into several variables.

I cannot get it to work. When i preview it all i get is "Array" on the page.

Am i doing something wrong? :confused:

schleppel
06-23-2005, 07:27 PM
Should the semi colon (;) on the line below be a comma (,)


$data = fgetcsv($handle, 1000, ";");

Further info; http://php.net/manual/en/function.fgetcsv.php

ItsMe
06-23-2005, 07:30 PM
It loads the data ok, but i cant explode it.

schleppel
06-23-2005, 07:40 PM
if ; is the delimiter, shouldn't you be exploding on the same delimiter?

faxie
06-23-2005, 11:05 PM
use the delimiter quantifier to prepend your variable :thumbsup:

ItsMe
06-23-2005, 11:11 PM
Thanks for the help guys. I have solved the prob now.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum