array ('name' => 'Laptop', 'price' => 800, 'stock' => 15), 'product2' => array ('name' => 'Smartphone', 'price' => 400, 'stock' => 20), 'product3' => array ('name' => 'Headphones', 'price' => 50, 'stock' => 50), ); echo "The price of product 2 is = ".$products['product2']['price']; echo "
"; if ($products['product3']['stock']>0) { echo "In Stock"; } else { echo "Out of Stock"; } $sum=0; $count=0; foreach($products as $prd => $num) { $sum = $sum + $num['price']; $count = $count + 1; } $avg = $sum / $count; echo "
"; echo "The average price of all the product is = ".$avg; echo "
"; ?> $info) { ?>
Product ID Name Price Stock Discounted Price