Re: Re: making an array from data in textfile
| From: | Stut | Date: | Sun, 23 Jul 2006 12:09:36 +0000 |
| Subject: | Re: Re: making an array from data in textfile | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-42248@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dave W wrote:
> Currently, here is my code:
>
> $file = 'ip.txt';
> $fh = fopen($file, 'r');
> $theData = fread($fh, filesize($file));
> fclose($fh);
> $ips = array($theData);
>
...
>
> Since it's a numeric array, I shouldn't need quotes around the ip octets.
> OK, well I did a debug and this is whats coming out:
>
> Array
> (
> [0] => 127.0.0.1,127.0.0.1,127.0.0.1
> )
PHP doesn't know what separates each element of the array, so you need
to tell it...
$ips = explode(',', $theData);
- -Stut
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEw2cA2WdB7L+YMm4RAlmaAJ4+cRJulnESdiZMZ5XtGWZ6Su5TzQCguSSY
fAqVdvlg4xX+RgrMepUJbc0=
=jI3V
-----END PGP SIGNATURE-----