Reputation:
I have a huge a CSV file which I parse to store the data in a PHP array. For different PHP files I have to parse it again and again to store it in the array. How can I prevent this by storing it in array and then have this array available to all PHP files?
Upvotes: 1
Views: 131
Reputation: 26753
apc_cache()
is what you want. http://us.php.net/manual/en/function.apc-fetch.php
Upvotes: 2
Reputation: 7341
Store the array in a file using serialize
:
file_put_contents('file.txt', serialize($data));
Then when you need to access it again, use unserialize
:
$data = unserialize(file_get_contents('file.txt'));
Upvotes: 0
Reputation: 10348
You can write it to a file. Use serialize() before. Then include the file each time you need it (include_once):
$my_csv_data = serialize($data);
Upvotes: 0