Reply to Re: What is max data length for preg_match_all? Script is dying! :(

Your name:

Reply:


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
-- -------------------------------------------------------------

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация