PHP memory exhausted when running through thousands of records
- by James Skidmore
I'm running the following code over a set of 5,000 results. It's failing due to the memory being exhausted.
foreach ($data as $key => $report) {
$data[$key]['data'] = unserialize($report['serialized_values']);
}
I know I can up the memory limit, but I'd like to run this without a problem instead. I'm not going to be able to keep upping the memory forever.
EDIT
The $data is in this format:
[1] => Array
(
[0] => 127654619178790249
[report_id] => 127654619178790249
[1] => 1
[user_id] => 1
[2] => 2010-12-31 19:43:24
[sent_on] => 2010-12-31 19:43:24
[3] =>
[fax_trans_id] =>
[4] => 1234567890
[fax_to_nums] => 1234567890
[5] => ' long html string here',
[html_content] => 'long html string here',
[6] => 'serialization_string_here',
[serialized_values] => 'serialization_string_here',
[7] => 70
[id] => 70
)