public function realpath($path)
    {
        $path = str_replace('\\', '/', rtrim($path, '/'));
        if ($path[0] != '/' && (strlen($path) < 2 || $path[1] != ':')) {
            $path = getcwd() . '/' . $path;
        }
        $parts = explode('/', $path);
        $path = [];
        foreach ($parts as $part) {
            if ($part == '..') {
                array_pop($path);
            } else if ($part != '.') {
                array_push($path, $part);
            }
        }
        return implode('/', $path);
    }
public function realpath($path)
    {
        $path = str_replace('\\', '/', rtrim($path, '/'));
        if ($path[0] != '/' && (strlen($path) < 2 || $path[1] != ':')) {
            $path = getcwd() . '/' . $path;
        }
        $parts = explode('/', $path);
        $path = [];
        foreach ($parts as $part) {
            if ($part == '..') {
                array_pop($path);
            } else if ($part != '.') {
                array_push($path, $part);
            }
        }
        return implode('/', $path);
    }
public function realpath ( $ path ) { $ path = str_replace ( '\\' , '/' , rtrim ( $ path , '/' ) ) ; if ( $ path [ 0 ] != '/' && ( strlen ( $ path ) < 2 || $ path [ 1 ] != ':' ) ) { $ path = getcwd ( ) . '/' . $ path ; } $ parts = explode ( '/' , $ path ) ; $ path = [ ] ; foreach ( $ parts as $ part ) { if ( $ part == '..' ) { array_pop ( $ path ) ; } else if ( $ part != '.' ) { array_push ( $ path , $ part ) ; } } return implode ( '/' , $ path ) ; }
Makes the path absolute and removes '.'
and '..' directories from it.

@param  string $path
@return string
Makes the path absolute and removes . and .. directories from it .