Re: making an array from data in textfile

From: Date: Sun, 23 Jul 2006 01:36:24 +0000
Subject: Re: making an array from data in textfile
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-42246@lists.php.net to get a copy of this message
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 ) Should I use fgets? On 7/22/06, Dave W <dabbaking@gmail.com> wrote:
OK, so I have this text file that holds a list of ip addresses like this: 127.0.0.1,127.0.0.1,127.0.0.1, 127.0.0.1,127.0.0.1 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. When I try to echo certain parts of the array like: echo $ips[0]; It's returning the whole array. The text file is exactly like an array so it shouldn't be a problem. -- Dave W
-- Dave W

« previous php.db (#42246) next »