I'm using preg_match_all to search through a file that I'm reading in. The file contains many lines of the following format and I'm extracting the numbers between the tags;
<float_array id="asdfasd_positions-array" count="6">1 2 3 4 5 6</float_array>
I'm using preg_match_all and it is working well - except it gets so far through the file then seems to stop.
preg_match_all("/\<float_array id\=\".+?positions.+?\" count\=\".+?\"\>(.+?)\<\/float_array\>/",$file, $results);
The file is 90,000 rows and about 8MB in size. I'm editing every third number in the extracted string and using str_replace to edit it back in to the file. The file is then written again. See the full script here;
http://pastie.org/4300537
The script is sucessfully replacing about half the entries and not doing anything with the second half of the file. I even copied a sucessfully edited line from higher in the file and pasted further down... and it wasn't edited further in the file. It's as if the array if full but memory_limit is set to 500M.
Any ideas?
EDIT: Solution Found
I found the problem - the size of the strings between the tags were too large in some instances and were skipped. I found the limit in PHP. pcre.backtrack_limit is set at 100000 and some strings were larger than this. So I increased this in the .htaccess file using the following line and it now works.
php_value pcre.backtrack_limit 5000000