This is a discussion on PHP Stops Processing on Multidimensional Associative Array within the PHP Language forums, part of the PHP Programming Forums category; When using a multidimensional associative array to cross-reference data in a second, single-dimensional array, PHP stops processing data ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
When using a multidimensional associative array to cross-reference data
in a second, single-dimensional array, PHP stops processing data after a few iterations. Memory usage according to the task manager doesn't seem to spike and CPU usage only gets as high as 11 to 13 percent. A sample script is provided below, any help or alternative solutions are welcome. (By the way, the script below works fine on Linux with the same version of Apache and PHP. Possibly a PHP configuration issue?) OS: Win2k HTTPD Server: Apache 2.0 PHP version: PHP 5.0.2 ============================= <html> <body> <?php $columnMap = array( "field1" => "u_field1", "field2" => "fk_field2", "field3" => "fk_field3", "field4" => "fk_field4", "field5" => "fk_field5", "field6" => "fk_field6", "field7" => "fk_field7", "field8" => "fk_field8"); $columnList = array( array("Alpha", "field1", 5), array("Bravo", "field_a", 20), array("Charlie", "field_b", 15), array("Delta", "field_c", 10), array("Echo", "field_d", 10), array("Foxtrot", "field_e", 15), array("Golf", "field_f", 10), array("Hotel", "field_g", 25) ); echo '<table>'; for( $i=0; $i < 520; $i++ ) { echo '<tr>'; for( $j=0; $j < count($columnList); $j++ ) { echo '<td>'.$i.', '.$j.'<br>'; $colName = $columnList[$j][1]; echo ' columnMap['.$colName.'] '.$columnMap[$colName].' '; echo '</td>'; } echo '</tr>'; } echo '</table>'; ?> </body> </html> |
|
|||
|
jdemello@apcinc.com wrote:
> When using a multidimensional associative array to cross-reference data > in a second, single-dimensional array, PHP stops processing data after > a few iterations. Memory usage according to the task manager doesn't > seem to spike and CPU usage only gets as high as 11 to 13 percent. A > sample script is provided below, any help or alternative solutions are > welcome. (By the way, the script below works fine on Linux with the > same version of Apache and PHP. Possibly a PHP configuration issue?) > > > OS: Win2k > HTTPD Server: Apache 2.0 > PHP version: PHP 5.0.2 > ============================= > > > <html> > <body> > > <?php error_reporting(E_ALL); ini_set('display_errors', '1'); > $columnMap = array( "field1" => "u_field1", <snip> > $columnList = array( > array("Alpha", "field1", 5), <snip> > echo '<table>'; > for( $i=0; $i < 520; $i++ ) > { 520 rows? Are you sure? > echo '<tr>'; > for( $j=0; $j < count($columnList); $j++ ) > { Each row with 8 cells? > echo '<td>'.$i.', '.$j.'<br>'; > $colName = $columnList[$j][1]; > ## echo ' columnMap['.$colName.'] '.$columnMap[$colName].' '; ## Perhaps your setup doesn't like to access inexistent data. ## Replace the line above by these lines: echo ' columnMap[', $colName, '] '; echo isset($columnMap[$colName]) ? $columnMap[$colName] : '(not set)'; echo ' '; <snip> -- Mail to my "From:" address is readable by all at http://www.dodgeit.com/ == ** ## !! ------------------------------------------------ !! ## ** == TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>) may bypass my spam filter. If it does, I may reply from another address! |
|
|||
|
Works fine for me on Apache 2.0 / PHP 4.3.9 under WinXP.
One thing I noticed is that you have no line breaks anywhere, which means you're sending 170kb line. I'm unaware of any line limits in PHP or Apache, but try changing '</tr>' to "</tr>\n". - Kevin <jdemello@apcinc.com> wrote in message news:1102957524.235720.75010@z14g2000cwz.googlegro ups.com... > When using a multidimensional associative array to cross-reference data > in a second, single-dimensional array, PHP stops processing data after > a few iterations. Memory usage according to the task manager doesn't > seem to spike and CPU usage only gets as high as 11 to 13 percent. A > sample script is provided below, any help or alternative solutions are > welcome. (By the way, the script below works fine on Linux with the > same version of Apache and PHP. Possibly a PHP configuration issue?) > > > OS: Win2k > HTTPD Server: Apache 2.0 > PHP version: PHP 5.0.2 > ============================= > > > <html> > <body> > > <?php > > $columnMap = array( "field1" => "u_field1", > "field2" => "fk_field2", > "field3" => "fk_field3", > "field4" => "fk_field4", > "field5" => "fk_field5", > "field6" => "fk_field6", > "field7" => "fk_field7", > "field8" => "fk_field8"); > > $columnList = array( > array("Alpha", "field1", 5), > array("Bravo", "field_a", 20), > array("Charlie", "field_b", 15), > array("Delta", "field_c", 10), > array("Echo", "field_d", 10), > array("Foxtrot", "field_e", 15), > array("Golf", "field_f", 10), > array("Hotel", "field_g", 25) > ); > > echo '<table>'; > for( $i=0; $i < 520; $i++ ) > { > echo '<tr>'; > for( $j=0; $j < count($columnList); $j++ ) > { > echo '<td>'.$i.', '.$j.'<br>'; > $colName = $columnList[$j][1]; > echo ' columnMap['.$colName.'] '.$columnMap[$colName].' '; > echo '</td>'; > } > echo '</tr>'; > } > echo '</table>'; > ?> > > </body> > </html> > |