Re: really no way to get byte size of variable?
| From: | Ivo Fokkema | Date: | Thu, 17 Jul 2003 07:42:41 +0000 |
| Subject: | Re: really no way to get byte size of variable? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-155559@lists.php.net to get a copy of this message | ||
"Baroiller Pierre-Emmanuel" <baroiller@daoditu.com> wrote in message
news:20030716220130.20461.qmail@pb1.pair.com...
> Hi,
>
> did you try count($value) and strlen($value) ?
> count($value) will give size of an array, and strlen($value) size of a
> string ...
Actually, count($value) returns the amount of values within the array, not
the size of it all.
If strlen($value) would be enough for you to determine the amount of bytes,
you could use this for an array (note that keys are stored as well and thus
take memory):
foreach ($array as $key => $val) {
$total_size += strlen($key) + strlen($val);
}
But I'm really not sure how PHP stores arrays, so I don't know if
$total_size is even close to the amount of bytes used for an array.
--
[Win2000 | Apache/1.3.23]
[PHP/4.2.3 | MySQL/3.23.53]
Ivo Fokkema
PHP & MySQL programmer
Leiden University Medical Centre
Netherlands