[PHP] Simple and Easy Solution.
Complexity
Time complexity: O(n)

Space complexity: O(n)
Code
# Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(n)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```php []
class Solution {

    /**
     * @param Integer $num
     * @return Integer
     */
    function minMaxDifference($num) {
        $strNum = strval($num);
        $maxNum = $strNum;
        $minNum = $strNum;

        for ($i = 0; $i < strlen($strNum); $i++) {
            if ($strNum[$i] != 9) {
                $maxNum = str_replace($strNum[$i], '9', $strNum);
                break;
            }
        }

        if ($strNum[0] != '0') {
            $minNum = str_replace($strNum[0], '0', $strNum);
        }

        return intval($maxNum) - intval($minNum);

        return $maxvalue - $minvalue;
    }
}
```
['PHP']