Answer the question
In order to leave comments, you need to log in
Substituting values in PHP's min() function?
Several variables are given in the class, some of them can be NULL, such a result is given by the function, if there is something in the request that it does not support.
When I have collected all the variables, they need to be compared and give the smallest value = the optimal supplier according to business logic.
// get the values of the variables
// check for NULL
// pushes anything that is not NULL into the min() function;
// return minimum value = best supplier
allowed:
$banan = 10;
$appleko = 12;
$tomat = NULL; because the supplier cannot deliver this product.
next comes min($banan, $yabloko, $tomat); // 10, 12, NULL
the result will naturally be NULL because it is the smallest, but it needs to return 10.
At the first stage, it is easy to sort the values with the is_null() function;
But how to set specific existing variables for the min() function?
For the query to be min($banan, $yabloko);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question