質問

$min_cost = min(NULLIF(value, 0))($cost_1, $cost_2, $cost_3, $cost_4);

Some costs on the database return $0.00, so that automatically becomes the $min_cost, even though there is values of more than zero on the other costs

I cant find much info on where the brackets should be on the NULLIF ? anyone help me?

役に立ちましたか?

解決

If you don't want to get rid of the 0 entries through SQL, try using array_filter.

array_filter() should get rid of the 0 entries

$array1 = array($cost_1, $cost_2, $cost_3, $cost_4);

$min_cost = min(array_filter($array1));
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top