On 17 March 2010 01:10, Robert Cummings rob...@interjinn.com wrote:
Rene Veerman wrote:
maybe you should be foreach()ing with references?
php.net : search foreach :
As of PHP 5, you can easily modify array's elements by preceding
$value with . This will assign reference instead of copying
On 15 March 2010 23:45, Daevid Vincent dae...@daevid.com wrote:
Anyone have a function that will return an integer of the number of
dimensions an array has?
/**
* Get the maximum depth of an array
*
* @param array $Data A reference to the data array
* @return int The maximum number of
Richard Quadling wrote:
On 15 March 2010 23:45, Daevid Vincent dae...@daevid.com wrote:
Anyone have a function that will return an integer of the number of
dimensions an array has?
/**
* Get the maximum depth of an array
*
* @param array $Data A reference to the data array
* @return int
This is one example where references actually decrease memory usage.
The main reason is the recursive nature of the function. Try
?php
echo memory_get_usage() . PHP_EOL;
$array = range(0,100);
$array[10] = range(0,10);
$array[20] = range(0,10);
$array[30] = range(0,10);
$array[40] =
Peter Lind wrote:
This is one example where references actually decrease memory usage.
The main reason is the recursive nature of the function. Try
?php
echo memory_get_usage() . PHP_EOL;
$array = range(0,100);
$array[10] = range(0,10);
$array[20] = range(0,10);
$array[30] = range(0,10);
Peter Lind wrote:
This is one example where references actually decrease memory usage.
The main reason is the recursive nature of the function. Try
BTW, it's not the recursive nature of the function causing the problem.
It's the movement of the internal pointer within the array. When it
Hmm, will probably have to look inside PHP for this ... the foreach
loop will copy each element as it loops over it (without actually
copying, obviously), however there's no change happening to the
element at any point and so there's nothing to suggest to the
copy-on-write to create a new instance
Peter Lind wrote:
Hmm, will probably have to look inside PHP for this ... the foreach
loop will copy each element as it loops over it (without actually
copying, obviously), however there's no change happening to the
element at any point and so there's nothing to suggest to the
copy-on-write to
maybe you should be foreach()ing with references?
php.net : search foreach :
As of PHP 5, you can easily modify array's elements by preceding
$value with . This will assign reference instead of copying the
value.
?php
$arr = array(1, 2, 3, 4);
foreach ($arr as $value) {
$value = $value * 2;
Rene Veerman wrote:
maybe you should be foreach()ing with references?
php.net : search foreach :
As of PHP 5, you can easily modify array's elements by preceding
$value with . This will assign reference instead of copying the
value.
?php
$arr = array(1, 2, 3, 4);
foreach ($arr as $value) {
Anyone have a function that will return an integer of the number of
dimensions an array has?
I did some quick searches and came up with nothing.
The closest was here of someone asking the same thing, but his solution
isn't right:
On Mon, 2010-03-15 at 16:45 -0700, Daevid Vincent wrote:
Anyone have a function that will return an integer of the number of
dimensions an array has?
I did some quick searches and came up with nothing.
The closest was here of someone asking the same thing, but his solution
isn't right:
Oh. I know it's not a simple solution to do right Ashley. And exacerbated
by the fact that each array dimension can have different dimensions as
well. This is why I wanted someone else's solution first before I spend
hours or days on one that works reliably. :)
_
From: Ashley Sheridan
On Mon, 2010-03-15 at 17:23 -0700, Daevid Vincent wrote:
Oh. I know it's not a simple solution to do right Ashley. And exacerbated
by the fact that each array dimension can have different dimensions as
well. This is why I wanted someone else's solution first before I spend
hours or days on
Daevid Vincent wrote:
Anyone have a function that will return an integer of the number of
dimensions an array has?
I did some quick searches and came up with nothing.
The closest was here of someone asking the same thing, but his solution
isn't right:
Jim Lucas wrote:
Daevid Vincent wrote:
Anyone have a function that will return an integer of the number of
dimensions an array has?
I did some quick searches and came up with nothing.
The closest was here of someone asking the same thing, but his solution
isn't right:
16 matches
Mail list logo