PHP Stops Processing on Multidimensional Associative Array

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


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-13-2004
jdemello@apcinc.com
 
Posts: n/a
Default PHP Stops Processing on Multidimensional Associative Array

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>

Reply With Quote
  #2 (permalink)  
Old 12-13-2004
Pedro Graca
 
Posts: n/a
Default Re: PHP Stops Processing on Multidimensional Associative Array

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!
Reply With Quote
  #3 (permalink)  
Old 12-13-2004
Kevin Lin
 
Posts: n/a
Default Re: PHP Stops Processing on Multidimensional Associative Array

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



Reply With Quote
  #4 (permalink)  
Old 12-13-2004
jdemello@apcinc.com
 
Posts: n/a
Default Re: PHP Stops Processing on Multidimensional Associative Array

> 520 rows? Are you sure?
> Each row with 8 cells?


Yes. And growing. Thanks for the advice. The 'isset(...)' function is
exactly what I needed.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:19 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0