public static function fixPath($path)
    {
        // Detect which direction of slash is "wrong"
        switch (DIRECTORY_SEPARATOR) {
            case '\\':
                $wrongDirection = '/';
                break;

            case '/':
            default:
                $wrongDirection = '\\';
                break;
        }

        if (false !== stristr($path, $wrongDirection)) {
            $path = str_replace($wrongDirection, DIRECTORY_SEPARATOR, $path);

            // In case of mixed slashes we maybe need to cleanup
            if (stristr($path, '\\\\')) {
                $path = str_replace('\\\\', '\\', $path);
            } elseif (stristr($path, '//')) {
                $path = str_replace('//', '/', $path);
            }
        }

        // Return corrected path
        return $path;
    }
public static function fixPath($path)
    {
        // Detect which direction of slash is "wrong"
        switch (DIRECTORY_SEPARATOR) {
            case '\\':
                $wrongDirection = '/';
                break;

            case '/':
            default:
                $wrongDirection = '\\';
                break;
        }

        if (false !== stristr($path, $wrongDirection)) {
            $path = str_replace($wrongDirection, DIRECTORY_SEPARATOR, $path);

            // In case of mixed slashes we maybe need to cleanup
            if (stristr($path, '\\\\')) {
                $path = str_replace('\\\\', '\\', $path);
            } elseif (stristr($path, '//')) {
                $path = str_replace('//', '/', $path);
            }
        }

        // Return corrected path
        return $path;
    }
public static function fixPath ( $ path ) { // Detect which direction of slash is "wrong" switch ( DIRECTORY_SEPARATOR ) { case '\\' : $ wrongDirection = '/' ; break ; case '/' : default : $ wrongDirection = '\\' ; break ; } if ( false !== stristr ( $ path , $ wrongDirection ) ) { $ path = str_replace ( $ wrongDirection , DIRECTORY_SEPARATOR , $ path ) ; // In case of mixed slashes we maybe need to cleanup if ( stristr ( $ path , '\\\\' ) ) { $ path = str_replace ( '\\\\' , '\\' , $ path ) ; } elseif ( stristr ( $ path , '//' ) ) { $ path = str_replace ( '//' , '/' , $ path ) ; } } // Return corrected path return $ path ; }
Fix slashes with "wrong" direction in a path and returns it.

@param string $path The path to correct slashes in

@author Benjamin Carl <opensource@clickalicious.de>

@return string The path with corrected slash-direction
@static
Fix slashes with wrong direction in a path and returns it .