Re: Question about parsing an array

From: Date: Thu, 07 Dec 2000 15:41:24 +0000
Subject: Re: Question about parsing an array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-29143@lists.php.net to get a copy of this message
Y don't ya try this one? how can this be correct? the { backets aren't even closed! and it seems to me that the contents of the file is already in an array. So what more do you need? If you mean that you want a link between the ID's and their place in the file, you need a 2-dimensional array with in the first place the ID and in the second the number. like following: <? $filename = c:/web/medsite/retrievedXML-12-07-2000.txt; $fd = fopen ($filename, "r"); $contents = fread ($fd, filesize ($filename)); $count=count($contents); for ($i=0; $i<$count; $i++) { echo $contents[$i]; array[$i][0]=$contents[$i]; } fclose ($fd); ?> At 16:23 07/12/2000 +0100, you wrote:
I have the file "retrievedXML-12-07-2000.txt" with some IDs. Number of IDs is unknown. Sometimes it's
possible to have more than in this file examlpe. My question is: If I'm open the file with code like this: <? $filename = c:/web/medsite/retrievedXML-12-07-2000.txt; $fd = fopen ($filename, "r"); $contents = fread ($fd, filesize ($filename)); $count=count($contents); for ($i=0; $i<$count; $i++) { echo $contents[$i]; fclose ($fd); ?> I got the number of arrays equal to 1. That is correct. But I would like to parse every IDs number from file to
single array or string, that I can use later in PHP code. Do you have any suggestions, example or advice? Thanks in advance, Vladimir


« previous php.general (#29143) next »