Counting a multidementional erray

I am seeing whats inside an Array

echo "<pre>";print_r($panelArray);echo '</pre>';

the result

Array
(
    [1] => Array
        (
            [0] => Array
                (
                    [format] => 0
                    [0] => 0
                    [phase] => 1
                    [1] => 1
                    [circuit] => 1
                    [2] => 1
                )

            [1] => Array
                (
                    [format] => 0
                    [0] => 0
                    [phase] => 2
                    [1] => 2
                    [circuit] => 2/4
                    [2] => 2/4
                )

        )

    [2] => Array
        (
            [0] => Array
                (
                    [format] => 0
                    [0] => 0
                    [phase] => 2
                    [1] => 2
                    [circuit] => 1/3
                    [2] => 1/3
                )

            [1] => Array
                (
                    [format] => 0
                    [0] => 0
                    [phase] => 1
                    [1] => 1
                    [circuit] => 2
                    [2] => 2
                )

        )

    [3] => Array
        (
            [0] => Array
                (
                    [format] => 0
                    [0] => 0
                    [phase] => 3
                    [1] => 3
                    [circuit] => 1/3/5
                    [2] => 1/3/5
                )

            [1] => Array
                (
                    [format] => 0
                    [0] => 0
                    [phase] => 2
                    [1] => 2
                    [circuit] => 2/4
                    [2] => 2/4
                )

        )

)

How can I count the number of indexes?

[1],[2], and [3] so the result should be 3

So you only want to count the top-level indexes?

The answer is in your question :wink: https://www.php.net/manual/en/function.count.php

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.