Created
October 9, 2019 03:35
-
-
Save rashid2003/328b99840ce55967c0c506f280bab7db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// we imagine the ( sccaned ) is array of scaned items the function will be like : | |
<?php | |
$sccaned = array("atv", "atv", "atv", "vga", "ipd", "ipd", "ipd", "ipd", "ipd"); | |
$atv_price = 109.50; | |
$mbp_price = 1399.99; | |
$vga_price = 30.00; | |
$ipd_price = 549.99; | |
$size = sizeof($sccaned); | |
for ($x = 0; $x <= $size; $x++) { | |
if ($sccaned[$x] == "atv") { | |
$atv ++; | |
}elseif($sccaned[$x] == "vga"){ | |
$vga ++; | |
}elseif($sccaned[$x] == "ipd"){ | |
$ipd ++; | |
} | |
}; | |
if($atv == 3){$atv = 2; }; | |
if($ipd > 4){$ipd_price = 499.99;}; | |
if($vga > 0){if($mbp > 0){$vga = 0;}}; | |
echo "Total : $", $total = $atv*$atv_price + $vga*$vga_price + $ipd*$ipd_price + $mbp*$mbp_price; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment