In php, Number of rows and columns in a 2 D array?

后端 未结 6 2033
野性不改
野性不改 2021-01-07 04:38

I have a two dimensional array with unknown number of elements.

$two_darray[row][column]; //there will be an unknown integer values instead of row and column

6条回答
  •  被撕碎了的回忆
    2021-01-07 04:40

    If you need to know an actual number, then you can use the sizeof() or count() functions to determine the size of each array element.

    $rows = count($two_darray) // This will get you the number of rows
    
    foreach ($two_darray as $row => $column)
    {
        $cols = count($row);
    }
    

提交回复
热议问题