Re: Re: making an array from data in textfile
| From: | Dave W | Date: | Sun, 23 Jul 2006 13:01:22 +0000 |
| Subject: | Re: Re: making an array from data in textfile | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-42250@lists.php.net to get a copy of this message | ||
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@gmail.com> 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