473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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>

Jul 17 '05 #1
3 2125
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
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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark | last post by:
Does Smarty support assigning multidimensional arrays? I've tried to get it working, but just can't get it. can someone help me? this is what I have in my php file: $side_bar = array('link'...
5
by: Golf Nut | last post by:
I am finding that altering and affecting values in elements in multidimensional arrays is a huge pain in the ass. I cannot seem to find a consistent way to assign values to arrays. Foreach would...
21
by: Leonardo | last post by:
I have the following associative array: $user=1; $user=1; $user=0; $user=1; $user=0; $user=1; $user=1;
2
by: paul | last post by:
Hi all, I have a 2D array, which I am trying to access, but I am having problems doing this: If, for instance, I use a nested for loop to go through the values, using something like echo...
6
by: Ant | last post by:
Hi, I'm trying to store some user input from a web form into an array, now the thing is I would like to store multiple users entries so I was thinking of using a multidimensional array so I...
8
by: Derek Basch | last post by:
Is there any way to associate name/value pairs during an array initialization? Like so: sType = "funFilter" filterTypeInfo = ; filterTypeInfo = new Array("type" : sType); I can do it using...
3
by: matthewburton | last post by:
Hi everyone, I'm trying to write a program that will search a body of text and replace certain words (say, A, B, and C) with different words that I think are more appropriate (A1, B1 and C1). I...
41
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in...
5
by: KDawg44 | last post by:
Hi, Is there a way to get a multidimensional associative array with the entire result set? I would like to get a an array like this: resultsArray How can I accomplish this? Can I do...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.