PHP – swap two variable values

For example, you have a function which takes two parameters int|float $min and int|float $max parameters and you need to swap variable values vise versa, in case if $max value is less then $min value.

You can do it using the following code below:

if ($min > $max) {
    list($min, $max) = [$max, $min];
}