RE: [PHP] Array Creation
| From: | Ford, Mike [LSS] | Date: | Thu, 10 Jan 2002 13:22:17 +0000 |
| Subject: | RE: [PHP] Array Creation | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-80023@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Bogdan Stancescu [mailto:mgv@fx.ro]
> Sent: 09 January 2002 20:56
>
> > while (!feof ($fp)) {
> > $line = fgets($fp, 4096);
> > $data = explode(",", str_replace("\"", "",
> > $line)); //using
> > str_replace to get rid of quote marks
> > //following line to see if data is correct
> > echo $data[0]." ".$data[1]."<br>";
>
> $theArray[$data[0]]=$data[1];
>
> >
> > }
> > fclose($fp);
>
> You should make sure you don't accidentally delete some
> double quotes inside
> the strings - maybe
> explode(",",substr($line,1,strlen($line)-2));
> would be a better option.
explode(",", substr($line, 1, -2));
would be even better!
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211