What is a multidimensional array in PHP and how is it commonly used in web development?

A multidimensional array in PHP is an array that contains one or more arrays as its elements. It is commonly used in web development to store and manipulate data in a structured way, such as storing information about users, products, or other related data. This type of array allows for organizing data hierarchically, making it easier to access and work with complex data structures.

// Creating a multidimensional array to store user information
$users = array(
    array('name' => 'John Doe', 'email' => 'john@example.com'),
    array('name' => 'Jane Smith', 'email' => 'jane@example.com'),
    array('name' => 'Bob Johnson', 'email' => 'bob@example.com')
);

// Accessing and displaying user information
foreach ($users as $user) {
    echo "Name: " . $user['name'] . ", Email: " . $user['email'] . "<br>";
}