see php.net/file or php.net/fread $file = "somefile.dat"; if ([EMAIL PROTECTED]($file)) return 0; $filecontent = file($file); $numbers = array(); if (is_array($filecontent) && count($filecontent)) { foreach($filecontent as $line) { // delete more than one space $line = ereg_replace("[ ]*"," ", $line); // explode whole line into array $numbers_temp = explode(" ", $line); // add temp arr to $numbers array $numbers = array_merge($numbers, $numbers_temp); } }
and now you have all the data in $numbers array... you DON'T need to convert strings to numbers. /tom On Tue, 9 Mar 2004 15:25:16 +0800 "Kenneth" <[EMAIL PROTECTED]> wrote: > My data file is sth like: > 2.208 2.18 2.415 2.283 2.234 2.155 2.389 2.201 > 2.204 2.181 2.43 2.285 2.231 2.164 2.387 2.197 > 2.2 2.179 2.429 2.29 2.225 2.181 2.385 2.195 > 2.196 2.178 2.424 2.291 2.225 2.213 2.386 2.19 > ........ > I would like to get these data in order to plot graph. > > I've tried to use fgets() and then convert them from string back into > array...but it seems doesn't work~ > > Thanks, > Kenneth > > > > "Jason Wong" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > On Monday 08 March 2004 09:04, Kenneth wrote: > > > > > I have a problem on getting content from a data file (data.txt). > > > I have many numbers in the file...all of them are about 2.XXX, and I > need > > > them to plot a graph. > > > > What does your data file look like? Show a few sample lines. > > > > > But I just can't read them out as a integer. > > > > What code did you use? > > > > -- > > Jason Wong -> Gremlins Associates -> www.gremlins.biz > > Open Source Software Systems Integrators > > * Web Design & Hosting * Internet & Intranet Applications Development * > > ------------------------------------------ > > Search the list archives before you post > > http://marc.theaimsgroup.com/?l=php-general > > ------------------------------------------ > > /* > > "Have you lived here all your life?" > > "Oh, twice that long." > > */ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- ========================================================================== Tomas Meinlschmidt, SBN3, MCT, MCP, MCP+I, MCSE, NetApp Filer & NetCache gPG fp: CB78 76D9 210F 256A ADF4 0B02 BECA D462 66AB 6F56 / $ID: 66AB6F56 GCS d-(?) s: a- C++ ULHISC*++++$ P+++>++++ L+++$>++++ E--- W+++$ N++(+) !o !K w(---) !O !M V PS+ PE Y+ PGP++ t+@ !5 X? R tv b+ !DI D+ G e>+++ h---- r+++ z+++@ ========================================================================== -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php