Simple, string manipulation
\n# Code\nphp []\nclass Solution {\n\n    /**\n     * @param Integer $num\n     * @return Integer\n     */\n    function minMaxDifference($num) {\n\n        $ma
\n# Code\n```php []\nclass Solution {\n\n    /**\n     * @param Integer $num\n     * @return Integer\n     */\n    function minMaxDifference($num) {\n\n        $max = (string)$num;\n        $min = (string)$num;\n\n        for ($i = 0; $i < strlen($max); $i++) {\n            if($max[$i] != \'9\'){\n                $max = str_replace($max[$i], \'9\', $max);\n                break;\n            }\n        }\n\n        $min = str_replace($min[0], \'0\', $min);\n\n        return $max - $min;\n    }\n}\n```
['PHP']