fork download
  1.  
  2. <?php
  3. $Discounts=array(0=>array('FromArea'=>1,'ToArea'=>0,'Master'=>0,'Slave'=>0),
  4. 1=>array('FromArea'=>0,'ToArea'=>10,'Master'=>5,'Slave'=>0),
  5. 2=>array('FromArea'=>5,'ToArea'=>0,'Master'=>0,'Slave'=>8),
  6. 3=>array('FromArea'=>0,'ToArea'=>0,'Master'=>1,'Slave'=>2),
  7. 4=>array('FromArea'=>0,'ToArea'=>1,'Master'=>7,'Slave'=>5),
  8. );
  9.  
  10. function equiv($Field,$OtherField)
  11. {
  12. if (empty($Field)) return true;
  13. else return $Field == $OtherField;
  14. }
  15.  
  16. function DiscountAmount($FromArea, $ToArea, $Master, $Slave)
  17. {
  18. global $Discounts;
  19. foreach ($Discounts as $R)
  20. if (equiv($FromArea, $R["FromArea"]) &&
  21. equiv($ToArea, $R["ToArea" ]) &&
  22. equiv($Master, $R["Master" ]) &&
  23. equiv($Slave, $R["Slave" ]))
  24. return true;
  25.  
  26. return false;
  27. }
  28.  
  29. echo DiscountAmount(0, 0, 0, 0);
  30. // your code goes here
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
1