Arnoud van der Leer
Arnoud van der Leer

Reputation: 25

php size of referenced array

I've got a multidimensional array, which refers to itself multiple times. like:

$foo = array(
  0 => array(
    & $foo[1],
    & $foo[2],
    'bar',
  ),
  1 => array(
    & $foo[0],
    & $foo[2],
    'bar',
  ),
  2 => array(
    & $foo[0],
    & $foo[1],
    'bar',
  ),
)

Is there a way to get the size (in bites or in amout of elements) of this array?

Kind Regards,

Tempestas Ludi.

Upvotes: 1

Views: 146

Answers (1)

Samuel Cook
Samuel Cook

Reputation: 16828

You can serialize the array, then determine the bytes using: mb_strlen()

$serialized = serialize($foo);
echo mb_strlen($serialized,'8bit');

Upvotes: 1

Related Questions