Re: [PHP] Need routine to tell me number of dimensions in array.

2010-03-17 Thread Richard Quadling
On 17 March 2010 01:10, Robert Cummings 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 t

Re: [PHP] Need routine to tell me number of dimensions in array.

2010-03-16 Thread Robert Cummings
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. This is possible only if iterated array can be referenced

Re: [PHP] Need routine to tell me number of dimensions in array.

2010-03-16 Thread Rene Veerman
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. This is possible only if iterated array can be referenced (i.e. is variable),

Re: [PHP] Need routine to tell me number of dimensions in array.

2010-03-16 Thread Robert Cummings
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 cr

Re: [PHP] Need routine to tell me number of dimensions in array.

2010-03-16 Thread Peter Lind
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

Re: [PHP] Need routine to tell me number of dimensions in array.

2010-03-16 Thread Robert Cummings
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 moves

Re: [PHP] Need routine to tell me number of dimensions in array.

2010-03-16 Thread Robert Cummings
Peter Lind wrote: This is one example where references actually decrease memory usage. The main reason is the recursive nature of the function. Try Doh, forgot about that :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (htt

Re: [PHP] Need routine to tell me number of dimensions in array.

2010-03-16 Thread Peter Lind
This is one example where references actually decrease memory usage. The main reason is the recursive nature of the function. Try wrote: > > > Richard Quadling wrote: >> >> On 15 March 2010 23:45, Daevid Vincent wrote: >>> >>> Anyone have a function that will return an integer of the number of >

Re: [PHP] Need routine to tell me number of dimensions in array.

2010-03-16 Thread Robert Cummings
Richard Quadling wrote: On 15 March 2010 23:45, Daevid Vincent 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 numb

Re: [PHP] Need routine to tell me number of dimensions in array.

2010-03-16 Thread Richard Quadling
On 15 March 2010 23:45, Daevid Vincent 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 levels in the array.

Re: [PHP] Need routine to tell me number of dimensions in array.

2010-03-15 Thread Robert Cummings
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: http://www.bigresource.c

Re: [PHP] Need routine to tell me number of dimensions in array.

2010-03-15 Thread Jim Lucas
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: > http://www.bigresource.com/PHP-

RE: [PHP] Need routine to tell me number of dimensions in array.

2010-03-15 Thread Ashley Sheridan
end > hours or days on one that works reliably. :) > > > _ > > From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] > Sent: Monday, March 15, 2010 4:44 PM > Subject: Re: [PHP] Need routine to tell me number of dimensions in array > > The only way to do

RE: [PHP] Need routine to tell me number of dimensions in array.

2010-03-15 Thread Daevid Vincent
y Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Monday, March 15, 2010 4:44 PM Subject: Re: [PHP] Need routine to tell me number of dimensions in array The only way to do it reliably would be to iterate the entire array, element by element, as all the elements of an array might not necessarily

Re: [PHP] Need routine to tell me number of dimensions in array.

2010-03-15 Thread Ashley Sheridan
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 righ

[PHP] Need routine to tell me number of dimensions in array.

2010-03-15 Thread Daevid Vincent
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: http://www.bigresource.com/PHP-count-array-dimensions-VrIahx1b.html