public static function exportVar($var, $indent = null, $guessTypes = false)
    {
        switch (gettype($var)) {
            case 'string':
                // guess boolean type for "1" and "0"
                if (true === $guessTypes) {
                    if ($var === '0' || $var === '') {
                        return 'false';
                    } elseif ($var === '1') {
                        return 'true';
                    }
                }
                return '\'' . $var . '\'';
            case 'array':
                $indexed = array_keys($var) === range(0, count($var) - 1);
                $row = [];
                foreach ($var as $key => $value) {
                    $row[] = $indent . "\t"
                        . ($indexed ? null : self::exportVar($key, null, $guessTypes) . ' => ')
                        . self::exportVar($value, $indent . "\t", $guessTypes);
                }
                return "[\n" . implode(",\n", $row) . "\n" . $indent . ']';
            case 'boolean':
                return $var ? 'true' : 'false';
            default:
                return var_export($var, true);
        }
    }
public static function exportVar($var, $indent = null, $guessTypes = false)
    {
        switch (gettype($var)) {
            case 'string':
                // guess boolean type for "1" and "0"
                if (true === $guessTypes) {
                    if ($var === '0' || $var === '') {
                        return 'false';
                    } elseif ($var === '1') {
                        return 'true';
                    }
                }
                return '\'' . $var . '\'';
            case 'array':
                $indexed = array_keys($var) === range(0, count($var) - 1);
                $row = [];
                foreach ($var as $key => $value) {
                    $row[] = $indent . "\t"
                        . ($indexed ? null : self::exportVar($key, null, $guessTypes) . ' => ')
                        . self::exportVar($value, $indent . "\t", $guessTypes);
                }
                return "[\n" . implode(",\n", $row) . "\n" . $indent . ']';
            case 'boolean':
                return $var ? 'true' : 'false';
            default:
                return var_export($var, true);
        }
    }
public static function exportVar ( $ var , $ indent = null , $ guessTypes = false ) { switch ( gettype ( $ var ) ) { case 'string' : // guess boolean type for "1" and "0" if ( true === $ guessTypes ) { if ( $ var === '0' || $ var === '' ) { return 'false' ; } elseif ( $ var === '1' ) { return 'true' ; } } return '\'' . $ var . '\'' ; case 'array' : $ indexed = array_keys ( $ var ) === range ( 0 , count ( $ var ) - 1 ) ; $ row = [ ] ; foreach ( $ var as $ key => $ value ) { $ row [ ] = $ indent . "\t" . ( $ indexed ? null : self :: exportVar ( $ key , null , $ guessTypes ) . ' => ' ) . self :: exportVar ( $ value , $ indent . "\t" , $ guessTypes ) ; } return "[\n" . implode ( ",\n" , $ row ) . "\n" . $ indent . ']' ; case 'boolean' : return $ var ? 'true' : 'false' ; default : return var_export ( $ var , true ) ; } }
Alternative var_export function for php >= 5.4 syntax
@param array|string $var
@param string|null $indent
@param boolean $guessTypes
@return string|null
Alternative var_export function for php > = 5 . 4 syntax