How can PHP arrays be effectively utilized to store and manage various product details in an online shop?

To store and manage various product details in an online shop using PHP arrays, you can create a multidimensional array where each element represents a product with its details such as name, price, description, and quantity. This allows for easy retrieval, updating, and manipulation of product information within the array.

// Create a multidimensional array to store product details
$products = array(
    array(
        'name' => 'Product 1',
        'price' => 10.99,
        'description' => 'Description of Product 1',
        'quantity' => 50
    ),
    array(
        'name' => 'Product 2',
        'price' => 19.99,
        'description' => 'Description of Product 2',
        'quantity' => 30
    ),
    array(
        'name' => 'Product 3',
        'price' => 24.99,
        'description' => 'Description of Product 3',
        'quantity' => 20
    )
);

// Accessing product details
echo $products[0]['name']; // Output: Product 1
echo $products[1]['price']; // Output: 19.99

// Adding a new product
$newProduct = array(
    'name' => 'Product 4',
    'price' => 14.99,
    'description' => 'Description of Product 4',
    'quantity' => 40
);
array_push($products, $newProduct);

// Updating product details
$products[2]['quantity'] = 25;

// Removing a product
unset($products[1]);