src/Components/AbstractSegment.php
protected function fetchRemainingSegment(array $data, $value)
    {
        $segment = implode($this->delimiter, $data);
        if ('' == $value) {
            if ($index = array_search('', $data, true)) {
                $left = array_slice($data, 0, $index);
                $right = array_slice($data, $index+1);

                return implode($this->delimiter, array_merge($left, $right));
            }

            return $segment;
        }

        $part = implode($this->delimiter, $this->formatRemoveSegment($value));

        $regexStart = '@(:?^|\\'.$this->delimiter.')';

        if (! preg_match($regexStart.preg_quote($part, '@').'@', $segment, $matches, PREG_OFFSET_CAPTURE)) {
            return null;
        }

        $pos = $matches[0][1];

        return substr($segment, 0, $pos).substr($segment, $pos + strlen($part) + 1);
    }
protected function fetchRemainingSegment(array $data, $value)
    {
        $segment = implode($this->delimiter, $data);
        if ('' == $value) {
            if ($index = array_search('', $data, true)) {
                $left = array_slice($data, 0, $index);
                $right = array_slice($data, $index+1);

                return implode($this->delimiter, array_merge($left, $right));
            }

            return $segment;
        }

        $part = implode($this->delimiter, $this->formatRemoveSegment($value));

        $regexStart = '@(:?^|\\'.$this->delimiter.')';

        if (! preg_match($regexStart.preg_quote($part, '@').'@', $segment, $matches, PREG_OFFSET_CAPTURE)) {
            return null;
        }

        $pos = $matches[0][1];

        return substr($segment, 0, $pos).substr($segment, $pos + strlen($part) + 1);
    }
protected function fetchRemainingSegment ( array $ data , $ value ) { $ segment = implode ( $ this -> delimiter , $ data ) ; if ( '' == $ value ) { if ( $ index = array_search ( '' , $ data , true ) ) { $ left = array_slice ( $ data , 0 , $ index ) ; $ right = array_slice ( $ data , $ index + 1 ) ; return implode ( $ this -> delimiter , array_merge ( $ left , $ right ) ) ; } return $ segment ; } $ part = implode ( $ this -> delimiter , $ this -> formatRemoveSegment ( $ value ) ) ; $ regexStart = '@(:?^|\\' . $ this -> delimiter . ')' ; if ( ! preg_match ( $ regexStart . preg_quote ( $ part , '@' ) . '@' , $ segment , $ matches , PREG_OFFSET_CAPTURE ) ) { return null ; } $ pos = $ matches [ 0 ] [ 1 ] ; return substr ( $ segment , 0 , $ pos ) . substr ( $ segment , $ pos + strlen ( $ part ) + 1 ) ; }
Remove some data from a given array

@param array $data  the original array
@param mixed $value the data to be removed (can be an array or a single segment)

@return string|null

@throws \RuntimeException If $value is invalid
Remove some data from a given array