0

I have a program that deletes Hand #[any number] from a file

<?php

$file_name = 'the_file.txt';

$file = file_get_contents($file_name);
$file_handle = fopen($file_name, "w+"); 


fwrite($file_handle, preg_replace("/^(Hand\s#\d+)/m", "", $file));

But if I try to input a large file I get:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 68353857 bytes)

I think the solution is to edit 134217728 bytes at a time how would I do this?

gus
  • 1,678
  • 2
  • 12
  • 11
  • Check http://stackoverflow.com/questions/561066/fatal-error-allowed-memory-size-of-134217728-bytes-exhausted-codeigniter-xml – Saty Jan 14 '16 at 06:02
  • @Saty I didn't see any talk of processing the file in parts only changing the memory limit wich I hear is a bad solution for reasons I don't fully understand – gus Jan 14 '16 at 06:16

0 Answers0