Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP Stops Processing on Multidimensional Associative Array

jdemello@apcinc.com
Guest
 
Posts: n/a
#1: Jul 17 '05
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>

Pedro Graca
Guest
 
Posts: n/a
#2: Jul 17 '05

re: PHP Stops Processing on Multidimensional Associative Array


jdemello@apcinc.com wrote:[color=blue]
> 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[/color]

error_reporting(E_ALL);
ini_set('display_errors', '1');
[color=blue]
> $columnMap = array( "field1" => "u_field1",[/color]
<snip>
[color=blue]
> $columnList = array(
> array("Alpha", "field1", 5),[/color]
<snip>
[color=blue]
> echo '<table>';
> for( $i=0; $i < 520; $i++ )
> {[/color]

520 rows? Are you sure?
[color=blue]
> echo '<tr>';
> for( $j=0; $j < count($columnList); $j++ )
> {[/color]

Each row with 8 cells?
[color=blue]
> echo '<td>'.$i.', '.$j.'<br>';
> $colName = $columnList[$j][1];
> ## echo ' columnMap['.$colName.'] '.$columnMap[$colName].' ';[/color]

## 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!
Kevin Lin
Guest
 
Posts: n/a
#3: Jul 17 '05

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...[color=blue]
> 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>
>[/color]


jdemello@apcinc.com
Guest
 
Posts: n/a
#4: Jul 17 '05

re: PHP Stops Processing on Multidimensional Associative Array


> 520 rows? Are you sure?[color=blue]
> Each row with 8 cells?[/color]

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

Closed Thread