By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,813 Members | 2,269 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,813 IT Pros & Developers. It's quick & easy.

PHP Stops Processing on Multidimensional Associative Array

P: n/a
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>

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
jd******@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!
Jul 17 '05 #2

P: n/a
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

<jd******@apcinc.com> wrote in message
news:11*********************@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>

Jul 17 '05 #3

P: n/a
> 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.

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.