473,396 Members | 1,833 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.

print_r and large arrays

Normally, if I use
$result=print_r($array,TRUE);
print_r prints nothing and $result is equal to the readable array.

However, if $array is very large, print_r prints the array and returns
nothing.

Is this correct ? I don't see anything about this in the the manual.

I have tried limiting the size to array to see exactly how large the
array has to be to trigger this behavior, but the exact size seems to be
variable or it depends on some other factor. Can anyone explain what is
the deciding factor ?
Mar 6 '06 #1
3 4142
meltdown wrote:
Normally, if I use
$result=print_r($array,TRUE);
print_r prints nothing and $result is equal to the readable array.

However, if $array is very large, print_r prints the array and returns
nothing.

Is this correct ? I don't see anything about this in the the manual.

I have tried limiting the size to array to see exactly how large the
array has to be to trigger this behavior, but the exact size seems to be
variable or it depends on some other factor. Can anyone explain what is
the deciding factor ?

You can use output buffering to get around this.

Just do:

ob_start();
print_r($array);
$value = ob_get_flush(); // or something like that!

I'm not sure why your problem is happening, but have you checked memory?
I bet it is a memory issue.

--
Carl Vondrick
www.carlsoft.net
usenet [at] carlsoft [dot] net
Mar 8 '06 #2
Carl Vondrick wrote:
meltdown wrote:
Normally, if I use
$result=print_r($array,TRUE);
print_r prints nothing and $result is equal to the readable array.

However, if $array is very large, print_r prints the array and returns
nothing.

Is this correct ? I don't see anything about this in the the manual.

I have tried limiting the size to array to see exactly how large the
array has to be to trigger this behavior, but the exact size seems to
be variable or it depends on some other factor. Can anyone explain
what is the deciding factor ? You can use output buffering to get around this.

Just do:

ob_start();
print_r($array);
$value = ob_get_flush(); // or something like that!


OK thanks.
I'm not sure why your problem is happening, but have you checked memory?
I bet it is a memory issue.


I assum you mean memory on the server. How do I check that ?
Mar 9 '06 #3
meltedown wrote:
I assum you mean memory on the server. How do I check that ?


The best way is to use SSH and run the top command. This will display
the process information.

If you do not have SSH access, then try this:
http://www.php.net/manual/en/functio...-get-usage.php

--
Carl Vondrick
www.carlsoft.net
usenet [at] carlsoft [dot] net
Mar 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Hayden Kirk | last post by:
I've used PHP for many smaller projects, but now im embarking on large corporate websites. After reading this: http://www.ukuug.org/events/linux2002/papers/html/php/index.html PHP does not...
6
by: guillaume | last post by:
I have to read and process a large ASCII file containing a mesh : a list of points and triangles. The file is 100 MBytes. I first tried to do it in memory but I think I am running out of memory...
7
by: mef526 | last post by:
I have had this problem for months now and it has been nagging me. I have a large project that has several C++ DLL's, one of them uses malloc / calloc / free for the other DLL's. I process very...
20
by: oswald.kluge | last post by:
Dear Reader, what efficient ways are there to OR two large memory regions? I'm especially interested in applying this operation to two large character arrays. I know memset and memcopy lets...
10
by: Peter Duniho | last post by:
This is kind of a question about C# and kind of one about the framework. Hopefully, there's an answer in there somewhere. :) I'm curious about the status of 32-bit vs 64-bit in C# and the...
6
by: lawpoop | last post by:
Hello! I am working on a map of a rather large php project that I've been working on. I hope to create a map of the files of the project that would look like the output of the unix 'tree'...
3
by: John | last post by:
I have two large arrays. Is there a rapid method to comaprs the two arrays and creat a third array of onlt thos items that the are in the first array but not the second array. I do it manually...
1
pbmods
by: pbmods | last post by:
Looking for a print_r() for JavaScript? Look no further! Finally, a decent way to figure out what's in that mysterious Array or Object! Note that this version of print_r() relies on (included)...
7
by: =?Utf-8?B?U3RldmVa?= | last post by:
First off, I am not sure if this belongs in this group or the C# group. It seems more like a C++ problem to me. Anyways... I have a C# project which links in an unmanaged C++ DLL, both built...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.