I have an array of product information. I have a loop that runs through the array and compares the prices to find the lowest one.
$rows = get_field('variations',$product_id);
if($rows){
$prices = array();
foreach($rows as $row){
$prices[] = $row['variation_price'];
}
//Getting the lowest price from the array
$lowest_price = min($prices);
}
echo $lowest_price;
However I now need to get the other information that is associated with the "lowest price" array set. IE. I need the ID of the lowest price product etc.
Any help is welcome!
Here is a dump of the array
Array
( [0] => Array ( [] => [variation_title] => Small Business [checkout] => cart [trial] => Array ( [0] => trial )
[variation_price] => 7
[variation_subscription_cycle] => /month
[variation_id] => 405
[variation_url] =>
[custom] => Array
(
[0] => Array
(
[custom_field] => 1 Domain
)
[1] => Array
(
[custom_field] => 1 Million QPM
)
[2] => Array
(
[custom_field] => 50 Records
)
[3] => Array
(
[custom_field] => DNS Alias
)
)
[css_styles] =>
)
[1] => Array
(
[] =>
[variation_title] => Medium Business
[checkout] => cart
[trial] => Array
(
[0] => trial
)
[variation_price] => 35
[variation_subscription_cycle] => /month
[variation_id] => 286
[variation_url] =>
[custom] => Array
(
[0] => Array
(
[custom_field] => 10 Domains
)
[1] => Array
(
[custom_field] => 5 Million QPM
)
[2] => Array
(
[custom_field] => 500 Records
)
[3] => Array
(
[custom_field] => DNS Alias
)
)
[css_styles] => ribbon
)
[2] => Array
(
[] =>
[variation_title] => Large Business
[checkout] => cart
[trial] => Array
(
[0] => trial
)
[variation_price] => 100
[variation_subscription_cycle] => /month
[variation_id] => 406
[variation_url] =>
[custom] => Array
(
[0] => Array
(
[custom_field] => 50 Domains
)
[1] => Array
(
[custom_field] => 15 Million QPM
)
[2] => Array
(
[custom_field] => 1,,500 Records
)
[3] => Array
(
[custom_field] => DNS Alias
)
)
[css_styles] =>
)
)