I am having a problem getting the right value in the array. I have an array that has a key of moq and costunit. I want to get the costunit if the given quantity is greater than or equal to the moq. I have the following array.
Array
(
[moq] => 1000
[costunit] => 0.44
)
Array
(
[moq] => 20000
[costunit] => 0.33
)
Array
(
[moq] => 30000
[costunit] => 0.30
)
Example 1: if the given qty is 25000 then the cost unit would be displayed is 0.33
Example 2: if the given qty is 1230 then the cost unit would be displayed is 0.44
$get_prices = array(
array( 'moq'=> 1000, 'costunit'=> 0.44 ),
array( 'moq'=> 20000, 'costunit'=> 0.33 ),
array( 'moq'=> 30000, 'costunit'=> 0.30 ),
);
$get_quantity = 30000;
foreach($get_prices as $get_price){
if($get_price['moq'] >= $get_quantity){
echo '<pre>';
print_r($get_price['costunit']);
echo '</pre>';
}
}
moqof1000is not greater than your given quantity of 1230.