ID: 47221 Updated by: j...@php.net Reported By: sgnutzmann at yahoo dot de Status: Open Bug Type: Arrays related Operating System: Windows XP PHP Version: 5.2.8 New Comment:
Please don't send me more spam. (never saw that and any direct mails to me will be deleted anyway) Previous Comments: ------------------------------------------------------------------------ [2009-01-27 13:55:35] sgnutzmann at yahoo dot de I just try the latest version 'php-5.2-win32-VC6-x86-latest.msi' (2009-Jan-27 12:00:00). This version has the same problem as PHP 5.2.8 (no return in 5 minutes from array_diff(), infinite loop?). I sent my test dataset 'TestData.txt' to j...@php.net. ------------------------------------------------------------------------ [2009-01-27 12:09:33] sgnutzmann at yahoo dot de PHP 5.2.6 has the same problem as PHP 5.2.8 ------------------------------------------------------------------------ [2009-01-27 10:32:48] sgnutzmann at yahoo dot de Complete test script (size of generated test file 5,865 KB) <?php $handle = fopen('TestData.txt','rb'); // size of first array $buffer = fgets($handle, 256); $buffer = str_replace("\r",'',$buffer); $buffer = str_replace("\n",'',$buffer); $count = (int) $buffer; echo 'Size of first array: '.$count."\r\n"; // elements of first array $idSales = array(); for ( $i = 0; $i < $count; $i++ ) { $buffer = fgets($handle, 256); $buffer = str_replace("\r",'',$buffer); $buffer = str_replace("\n",'',$buffer); $idSales[] = $buffer; } // for ( $i = 0; $i < $count; $i++ ) // size of second array $buffer = fgets($handle, 256); $buffer = str_replace("\r",'',$buffer); $buffer = str_replace("\n",'',$buffer); $count = (int) $buffer; echo 'Size of second array: '.$count."\r\n"; // elements of second array $idInv = array(); for ( $i = 0; $i < $count; $i++ ) { $buffer = fgets($handle, 256); $buffer = str_replace("\r",'',$buffer); $buffer = str_replace("\n",'',$buffer); $idInv[] = $buffer; } // for ( $i = 0; $i < $count; $i++ ) fclose($handle); echo "Start of array_diff\r\n"; $unknown = array_diff ( $idSales, $idInv ); echo 'Number of unknown identifier '.count($unknown)."\r\n"; ?> First lines of test file: 76906 #00/1109 #00/1162 #00/1163 #00/1335 #00/1337 Result, if I use PHP 5.2.4: Size of first array: 76906 Size of second array: 433959 Start of array_diff Number of unknown identifier 17826 No result from array_diff, if I use PHP 5.2.8 (without any extension) ------------------------------------------------------------------------ [2009-01-26 17:58:51] sgnutzmann at yahoo dot de Description: ------------ I use the function array_diff() to compare two sorted string-arrays with numerical keys (array sizes are 76,906 and 433,959, string sizes in all array elements less than 20 characters). With PHP 5.2.4 the function returns very fast (just few seconds), with PHP 5.2.8 I kill PHP.exe after 30 minutes(!) without result. PHP.INI: memory_limit = 1536M extension=php_pdo.dll extension=php_zip.dll extension=php_pdo_odbc.dll Reproduce code: --------------- // $Sales and $Inv read previously from file system $idSales = array(); foreach ( $Sales as $i => $data ) $idSales[$i] = '#'.$data[2]; array_multisort ($idSales, $Sales); $idInv = array(); foreach ( $Inv as $i => $data ) $idInv[$i] = '#'.$data[1]; array_multisort ($idInv, $Inv); echo "Start array_diff\n"; $unknown = array_diff ( $idSales, $idInv ); echo "End array_diff\n"; Expected result: ---------------- see description Actual result: -------------- no result in 30 minutes ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47221&edit=1