php unpack function

From: Date: Wed, 23 May 2001 20:28:36 +0000
Subject: php unpack function
Groups: php.general 
Request: Send a blank email to php-general+get-54116@lists.php.net to get a copy of this message
Hi there- I am using the PHP unpack function to take a binary formatted file with 10's of thousands of signed short integers stored in it, to take the file (which is in PHP STRING form) and extract the short integer values from it. The problem I am having is when reading all the documentation for the pack/unpack function, I have been unable to figure out a way to only take a small subset of the data. For instance, my file is basically just thousands of temperature values, taken 4 times a day, over a period of 20 years. Let's say I wanted to get a year's worth of temperatures, from the 10th year into the file (so I would need the 4x365x10) th temperature value from the file. How would I use the unpack function to just select the (4x365x10)th through the (4x365x10)+(4x365)th value (basically year 10's entire temperature range). I see in the documentation I can specify how many shorts to extract STARTING from the first one, how would I specify, or is it even possible to specify a different starting location to begin extraction from. I cannot write the string to a file, and then use fseek while reading the file back in to skip to a postion and unpack from there. The way that the application is structured, I have to begin my extraction at the point where I already have the file in terms of a binary encoded string. So if anyone has any suggestions, I would greatly appreciate it. Please reply back to my account here at work if you are posting a reply on the forum: Thanks for your time. ------------------------------------------------------- Chris Mattmann Science Data Management and Archiving Chris.Mattmann@jpl.nasa.gov NASA-JPL Pasadena, CA 91109-8099 Office: 300-324C Phone: 818-354-8810

« previous php.general (#54116) next »