Unlimited Usenet
day retention, 99% Completion, Unlimited Access, Free Trial!

array size in bytes

This is a discussion on array size in bytes within the PHP General forums, part of the PHP Programming Forums category; Hi, Exists in PHP function returning array size in bytes ? (For saving array into shared memory without serialize.) Thnx. Roman...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-02-2006
Roman Rumisek
 
Posts: n/a
Default array size in bytes

Hi,

Exists in PHP function returning array size in bytes ?
(For saving array into shared memory without serialize.)

Thnx. Roman
Reply With Quote
  #2 (permalink)  
Old 10-02-2006
Richard Lynch
 
Posts: n/a
Default Re: [PHP] array size in bytes

On Mon, October 2, 2006 3:07 am, Roman Rumisek wrote:
> Exists in PHP function returning array size in bytes ?
> (For saving array into shared memory without serialize.)


No.

And you could maybe write one, if it was all strings in the array, but
you're gonna be screwed when PHP 6 with Unicode comes out, cuz the
number of bytes "depends" on where you're gonna store it, in which
charset, and several other factors...

There was a thread on PHP-internals last month about the the strlen()
function should or shouldn't do for that -- and if sizeof() should or
shouldn't do something different.

You probably shouldn't be poking it into shared memory without
serializing it anyway, I don't think...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
Reply With Quote
  #3 (permalink)  
Old 10-02-2006
tedd
 
Posts: n/a
Default Re: [PHP] array size in bytes

At 4:18 PM -0500 10/2/06, Richard Lynch wrote:
>On Mon, October 2, 2006 3:07 am, Roman Rumisek wrote:
>> Exists in PHP function returning array size in bytes ?
>> (For saving array into shared memory without serialize.)

>
>No.
>
>And you could maybe write one, if it was all strings in the array, but
>you're gonna be screwed when PHP 6 with Unicode comes out, cuz the
>number of bytes "depends" on where you're gonna store it, in which
>charset, and several other factors...
>
>There was a thread on PHP-internals last month about the the strlen()
>function should or shouldn't do for that -- and if sizeof() should or
>shouldn't do something different.
>
>You probably shouldn't be poking it into shared memory without
>serializing it anyway, I don't think...
>



How about saving the array as a file and then do a filesize()?

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
Reply With Quote
  #4 (permalink)  
Old 10-03-2006
Chris Boget
 
Posts: n/a
Default Re: [PHP] array size in bytes

> How about saving the array as a file and then do a filesize()?

Wouldn't this work?

$arraySize = strlen( implode( '', $array ));

Though, additional work would need to be done for nested arrays.

thnx,
Chris
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:45 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0