// Creating a multidimensional array
$matrix = array(
array(1, 2, 3),
array(4, 5, 6),
array(7, 8, 9)
);
// Accessing elements in a two-dimensional array
echo $matrix[0][1]; // Outputs 2
echo $matrix[1][2]; // Outputs 6
echo $matrix[2][0]; // Outputs 7
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter