อยากสอบถามเกี่ยวกับโค้ด php ค่ะ
จะดึงข้อมูลจากอาเรย์มาแสดง โดยใช้ sum_r แสดงข้อมูลทั้ง 3 อาเรย์ ยังไงคะ
<?
$Product = array(
array( 'Product_id' => '00000' , 'Product_list' => 'xxxxxxxxxx' , 'Product_stock' => '0000','Product_quantity'=>'10', 'Product_price' => '100' , 'Product_discount' => '50'),
array( 'Product_id' => '11111' , 'Product_list' => 'xxxxxxxxxx' , 'Product_stock' => '0000','Product_quantity'=>'20', 'Product_price' => '200' , 'Product_discount' => '100'),
array( 'Product_id' => '22222' , 'Product_list' => 'xxxxxxxxxx' , 'Product_stock' => '0000', 'Product_quantity'=>'30','Product_price' => '300' , 'Product_discount' => '200')
);
$total = 0;
foreach ($Product as $key => $value) {
$sum_r = ($value['Product_quantity'] * $value['Product_price'] - $value ['Product_discount']);
} echo $sum_r;
?>
อยากสอบถามโค้ดเกี่ยวกับการดึงข้อมูลจาก Array โค้ด PHP ค่ะ
จะดึงข้อมูลจากอาเรย์มาแสดง โดยใช้ sum_r แสดงข้อมูลทั้ง 3 อาเรย์ ยังไงคะ
<?
$Product = array(
array( 'Product_id' => '00000' , 'Product_list' => 'xxxxxxxxxx' , 'Product_stock' => '0000','Product_quantity'=>'10', 'Product_price' => '100' , 'Product_discount' => '50'),
array( 'Product_id' => '11111' , 'Product_list' => 'xxxxxxxxxx' , 'Product_stock' => '0000','Product_quantity'=>'20', 'Product_price' => '200' , 'Product_discount' => '100'),
array( 'Product_id' => '22222' , 'Product_list' => 'xxxxxxxxxx' , 'Product_stock' => '0000', 'Product_quantity'=>'30','Product_price' => '300' , 'Product_discount' => '200')
);
$total = 0;
foreach ($Product as $key => $value) {
$sum_r = ($value['Product_quantity'] * $value['Product_price'] - $value ['Product_discount']);
} echo $sum_r;
?>