Had the same problem not long ago and I didn't find a simple solution
either. My solution at the time was the painfully slow one - walking the
array and storing strlen for both key and value. Since you have a large
array, this probably doesn't do for you.

A faster but less accurate solution would be storing
round(strlen(serialize($array))*$coefficient), where you should approximate
$coefficient for your average array (the less the average array element
size, the smaller the coefficient).

I know, these are both rudimentary and ugly solutions but I didn't find any
better - these are the solutions I considered when I had the same problem.

Bogdan

Stefan Rusterholz wrote:

> Hi
>
> I have a rather large array in my script and I was interested how much
> memory it uses. Is there a way to get the size of an array in bytes?
> BTW: I did RTFM and didn't find an accomidating function, so if there is
> one, please point me to it...
>
> TIA
> Stefan Rusterholz
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to