I’m trying to shorten my code using the ternary operator.
This is my original code:
if ($type = "recent") {
$OrderType = "sid DESC";
} elseif ($type = "pop") {
$OrderType = "counter DESC";
} else {
$OrderType = "RAND()";
}
How can I use the ternary operator in my code instead of ifs/elses?
$OrderType = ($type = "recent") ? "sid DESC" : "counter DESC" ;
This is the code I tried, but have no idea how to add an “elseif part” to it.