|
Posted by Jeff North on 12/09/07 02:38
On Sat, 8 Dec 2007 08:37:23 -0800 (PST), in comp.lang.php
alexandis@gmail.com
<105b3f56-6e49-417d-9e1b-63614b56cdb5@j44g2000hsj.googlegroups.com>
wrote:
>| I parse big file ~ 40Mb
>| preg_match_all("/".$preg_pattern."/i", $content, $matches,
>| PREG_SET_ORDER)
>| - script dies without any message!
>|
>| If I do
>| preg_match_all("/".$preg_pattern."/i", substr($content, 0, 20000000),
>| $matches, PREG_SET_ORDER)
>| - everything's ok
>|
>| Problem exists on Solaris OS, PHP4, locally i use Denver pack (Apache
>| + PHP4) and no any problem here.
>| I've checked php.ini and can't see any relevant setting.
>|
>| I do realize I can chunk input data into pieces ~20Mb, but I'd like to
>| hear why above function doesn't work, is it a bug?
>|
>| p.s. 40mb is really read from input file into $content, it's checked!
I maybe way off the mark here but... set_time_limit(<your value>);
I'm wondering if it just a timing problem with processing such a large
file.
To test you might want to do the following:
$time_start = microtime();
preg_match_all("/".$preg_pattern."/i",substr($content, 0,
20000000),$matches,PREG_SET_ORDER);
$time_end = microtime();
$diff = number_format(((substr($time_end,0,9)) +
(substr($time_end,-10)) - (substr($time_start,0,9)) -
(substr($time_start,-10))),4);
echo "<br />timing : ".$diff."s";
Once you've found an appropriate time you could the use:
set_time_limit(<your value>);
preg_match_all("/".$preg_pattern."/i",$content,$matches,PREG_SET_ORDER);
-- -------------------------------------------------------------
jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
-- -------------------------------------------------------------
Navigation:
[Reply to this message]
|