Hello, immediately I ask you not to kick much, a newbie in PHP, I am more used to programming in Delphi ...
Actually, the essence of the issue and the problem itself: There is a script that at a certain time receives a large array of strings (300-500) ... in each row there are 2-4 words (small sentence or phrase), the task is to translate all this text into Ukrainian, I use Yandex API ( http://code.google.com/p/translate-api/source/browse/trunk/)
<? include_once 'Yandex_Translate.php'; include_once 'Big_Text_Translate.php'; header('Content-Type: text/html; charset=win-1251'); function GTR($str,$in1,$in2) { $translator = new Yandex_Translate(); $bigText = $str; $textArray = Big_Text_Translate::toBigPieces($bigText); $numberOfTextItems = count($textArray); foreach ($textArray as $key=>$textItem){ $translatedItem = $translator->yandexTranslate($in1, $in2, $textItem); $translatedArray[$key] = $translatedItem; } $translatedBigText = Big_Text_Translate::fromBigPieces($translatedArray); return $translatedBigText; } for ($l = 0; $l <= count($array); $l++) { $text=iconv('windows-1251','utf-8//IGNORE',$array[$l]); $text=iconv('utf-8','windows-1251//IGNORE',GTR($text,'ru','uk')); echo text; } ?>
but in the end, the error Fatal error: Maximum execution time of 30 seconds exceeded in \ Yandex_Translate.php on line 43
The question is the following, for example, or break this array into small ones and translate it in turn, or make some kind of timeout before each sending a transfer request, in order to translate it normally ...
I will be glad to any advice !!!