Re: Re: Array sizes?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Paul Novitski wrote:
Anders Norrbring wrote:

Maybe I'm just blind, but I can't find any way to count an array size in bytes? I have a quite big array with multiple data formats in it, and I would like to know how big it is in bytes...


At 01:05 AM 2/8/2006, Barry wrote:

I don't think a "function" exists, but i would probably use (for benchmarking) a recursive foreach in combination with strlen.
And add it all up.
(This is probably some work for the PC so that's why benchmarking)



It would be interesting to know whether that method was faster or slower than using this:

        $iLen = strlen(implode("", $aArray));

Paul

At least less memory using. Since foreach sets pointers and reads only array fields and not the whole array.
Your example would pump the whole array in one var.

But yeah, would be fun to know.
you can use microtime to benchmark that.
Please use it :)

barry

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux