Re: 2D array from file
| From: | Chris Lee | Date: | Wed, 26 Sep 2001 20:30:32 +0000 |
| Subject: | Re: 2D array from file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-68918@lists.php.net to get a copy of this message | ||
have you thought of just using
http://www.php.net/manual/en/function.serialize.php
http://www.php.net/manual/en/function.unserialize.php
its alot easier.
--
Chris Lee
lee@mediawaveonline.com
"John Frenzel" <jfrenze@attglobal.net> wrote in message
news:20010926173648.56589.qmail@pb1.pair.com...
> I have created a 2D array, then written it into a tet file. The file is
> written such that all the secondary array elements (the rows) are seperate
> lines, with the "columns" tab-delimited. Now I'd like to read this file
back
> into a 2D array. I thought this should work:
>
>
> $array_file = file ("array.dat");
> for ($k=0; $k <= 63; $k++)
> {
> $array[$k] = explode( "\t", $array_file[$k] );
> }
>
> I know that $array[$k] is a valid variable, and that explode returns an
> array, so I'm not clear why this isn't working. If I use $array = explode(
> "\t", $array_file[$k] ); I get the line without any trouble. What am I
> missing?
>
> Thanks
>
> --- John Frenzel
>
>