Re: Re: making an array from data in textfile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I figured it out before, but I didn't hit reply all. I used files() and
newlines to create it. Would using explode be a more reliable way?

On 7/23/06, Stut <stuttle@xxxxxxxxx> wrote:

-----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-----




--
Dave W

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux