src/FileInfo.php
public function strip($strip)
    {
        $filename = $this->getPath();
        $striplen = strlen($strip);
        if (is_int($strip)) {
            // if $strip is an integer we strip this many path components
            $parts = explode('/', $filename);
            if (!$this->getIsdir()) {
                $base = array_pop($parts); // keep filename itself
            } else {
                $base = '';
            }
            $filename = join('/', array_slice($parts, $strip));
            if ($base) {
                $filename .= "/$base";
            }
        } else {
            // if strip is a string, we strip a prefix here
            if (substr($filename, 0, $striplen) == $strip) {
                $filename = substr($filename, $striplen);
            }
        }

        $this->setPath($filename);
    }
public function strip($strip)
    {
        $filename = $this->getPath();
        $striplen = strlen($strip);
        if (is_int($strip)) {
            // if $strip is an integer we strip this many path components
            $parts = explode('/', $filename);
            if (!$this->getIsdir()) {
                $base = array_pop($parts); // keep filename itself
            } else {
                $base = '';
            }
            $filename = join('/', array_slice($parts, $strip));
            if ($base) {
                $filename .= "/$base";
            }
        } else {
            // if strip is a string, we strip a prefix here
            if (substr($filename, 0, $striplen) == $strip) {
                $filename = substr($filename, $striplen);
            }
        }

        $this->setPath($filename);
    }
public function strip ( $ strip ) { $ filename = $ this -> getPath ( ) ; $ striplen = strlen ( $ strip ) ; if ( is_int ( $ strip ) ) { // if $strip is an integer we strip this many path components $ parts = explode ( '/' , $ filename ) ; if ( ! $ this -> getIsdir ( ) ) { $ base = array_pop ( $ parts ) ; // keep filename itself } else { $ base = '' ; } $ filename = join ( '/' , array_slice ( $ parts , $ strip ) ) ; if ( $ base ) { $ filename .= "/$base" ; } } else { // if strip is a string, we strip a prefix here if ( substr ( $ filename , 0 , $ striplen ) == $ strip ) { $ filename = substr ( $ filename , $ striplen ) ; } } $ this -> setPath ( $ filename ) ; }
Strip given prefix or number of path segments from the filename

The $strip parameter allows you to strip a certain number of path components from the filenames
found in the tar file, similar to the --strip-components feature of GNU tar. This is triggered when
an integer is passed as $strip.
Alternatively a fixed string prefix may be passed in $strip. If the filename matches this prefix,
the prefix will be stripped. It is recommended to give prefixes with a trailing slash.

@param  int|string $strip
Strip given prefix or number of path segments from the filename