Php get array’s data size

arraysPHPsize

Having this array:

Array
(
    [_block1] => Array
        (
            [list] => Array
            (
                 [sub-list] => Array
                 (
                 )
            )
            [links] => Number
            [total] => Number
            ...
        )
    [_block2] => Array
        (
             [@attributes] => Array
             (
             )
             [title] => ...
             [data] => Array ()
             ...
        )
    [_block3] => Array
        (
             ..
        )
)

Those blocks contain data returned by api. Knowing that each api returns data in a different way/structure I need to measure/calculate the data/size inside of each and one of them and then do if data > X or < do something.

Is it possible? I have searched google but I only found count() and that isn't what I need to make this work.

Edit:
Each and of the those blocks contain many other sub blocks, and I was thinking of calculating the data size in bytes, because count wont do the job here.

Best Answer

echo  mb_strlen(serialize((array)$arr), '8bit');