Re: Re: making an array from data in textfile

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

 



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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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

  Powered by Linux