You may find operator switch very useful (Switch in PHP). Something like this:
...
switch ($quantity) {
case (($quantity >= 1) && ($quantity <= 1000)):
$multiplicator = 1.5;
echo $quantity * $multiplicator;
break;
case (($quantity >= 1001) && ($quantity <= 5000)):
$multiplicator = 1.2;
echo $quantity * $multiplicator;
break;
case (($quantity >= 5001) && ($quantity <= 10000)):
$multiplicator = 1.2;
echo $quantity * $multiplicator;
break;
case ($quantity > 10000):
echo 'Quantity must be less then 10000!';
break;
}
....
Edited: another option using loop:
...
$limits_array = array(
0 => array(
'min' => 1,
'max' => 1000,
'mul' => 1.5,
),
1 => array(
'min' => 1001,
'max' => 5000,
'mul' => 1.2,
),
2 => array(
'min' => 5001,
'max' => 10000,
'mul' => 1,
),
);
foreach ($limits_array as $limits)
if (($quantity >= $limits['min']) && ($quantity <= $limits['max']) {
echo $quantity * $limits['mul'];
break;
}
if ($quantity > $limits['max'])
echo 'Quantity must be less then 10000!';
...
Please notice, that after foreach last value element ($value is a common name for it, there it is $limits) still stores the last item from array. Take a look at brackets.