i have an array of a fixed length...within each element of the array I am only allowed to write a maximum of 1kb of binary data...how can I 'chunk' data to the array like that?
can it be done in php?
i have an array of a fixed length...within each element of the array I am only allowed to write a maximum of 1kb of binary data...how can I 'chunk' data to the array like that?
can it be done in php?
It can surely be done, but you'll have to program your own function for storing and retrieving, and you'll have to keep an index of the chunks.
But just a question:
- why is your array of fixed length???
To do that properly, you should store your data (well, the data that could be >1024K in an other array and keep only an index in your main array.
That second array would consist of 2 elements.
1 - The data.
2 - The position inside the array of the next chunk.
So your RETRIEVE function will do something like:
- from the index in main array (mainarray[0]=5), it temporarely store the data from index 5 (secondarray[5,0]) in a variable and, if the position is valid (secondarray[5,1]>=0) it go from index to index and copies the content until it hits a -1 or, as you wish, any invalid array position.
I hope i answered your question.
S. Breton
i am doing this for a university class...the assignment is to write a simulated file system. The fixed length array is my mock harddrive. And the fixed length of the elements in the array is supposed to represent the blocks.