Hello guys, I would like to output only the name of each product side by side with the price of that product. I don't want to output the ID or something else.
<?php
$a = array(
array('id' => '1', 'name' => 'Milch','price' => '12'),
array('id' => '2', 'name' => 'Reis','price' => '13'),
array('id' => '3', 'name' => 'Öl','price' => '14'),
array('id' => '4', 'name' => 'Salz','price' => '15'),
array('id' => '5', 'name' => 'Zucker','price' => '16'),
);
foreach ($a as $key => $value){
print_r($a[$key]);
}
?>
foreach ($a as $product) {
echo $product['name'] . ': $' . $product['price'] . '<br />';
}
<?
$a = array(
array('id' => '1', 'name' => 'Milch','price' => '12'),
array('id' => '2', 'name' => 'Reis','price' => '13'),
array('id' => '3', 'name' => 'Öl','price' => '14'),
array('id' => '4', 'name' => 'Salz','price' => '15'),
array('id' => '5', 'name' => 'Zucker','price' => '16'),
);
foreach ($a as $key => $value){
echo ( $value['name'] . ' ' . $value['price'] . PHP_EOL );
}
?>
php select.php
Milch 12
Reis 13
Öl 14
Salz 15
Zucker 16