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

后端 未结 6 1887
野性不改
野性不改 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:46

    This is what i do: My superheroes' array:

    $superArray[0][0] = "DeadPool";
    $superArray[1][0] = "Spiderman";
    $superArray[1][1] = "Ironman";
    $superArray[1][2] = "Wolverine";
    $superArray[1][3] = "Batman";
    

    Get size :

    echo count( $superArray ); // Print out Number of rows = 2
    echo count( $superArray[0] ); // Print Number of columns in $superArray[0] = 1
    echo count( $superArray[1] ); // Print Number of columns in $superArray[1] = 4
    

    php

提交回复
热议问题