Optimizing PHP code (trying to determine min/max/between case)
- by Swizzh
I know this code-bit does not conform very much to best coding practices, and was looking to improve it, any ideas?
if ($query['date_min'] != _get_date_today())
$mode_min = true;
if ($query['date_max'] != _get_date_today())
$mode_max = true;
if ($mode_max && $mode_min)
$mode = "between";
elseif ($mode_max && !$mode_min)
$mode = "max";
elseif (!$mode_max && $mode_min)
$mode = "min";
else
return;
if ($mode == "min" || $mode == "between") {
$command_min = "A";
}
if ($mode == "max" || $mode == "between") {
$command_max = "B";
}
if ($mode == "between") {
$command = $command_min . " AND " . $command_max;
} else {
if ($mode == "min")
$command = $command_min;
if ($mode == "max")
$command = $command_max;
}
echo $command;