src/ICal/ICal.php
protected function fileOrUrl($filename)
    {
        $options = array();
        if (!empty($this->httpBasicAuth) || !empty($this->httpUserAgent)) {
            $options['http'] = array();
            $options['http']['header'] = array();

            if (!empty($this->httpBasicAuth)) {
                $username  = $this->httpBasicAuth['username'];
                $password  = $this->httpBasicAuth['password'];
                $basicAuth = base64_encode("{$username}:{$password}");

                array_push($options['http']['header'], "Authorization: Basic {$basicAuth}");
            }

            if (!empty($this->httpUserAgent)) {
                array_push($options['http']['header'], "User-Agent: {$this->httpUserAgent}");
            }
        }

        $context = stream_context_create($options);

        if (($lines = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES, $context)) === false) {
            throw new \Exception("The file path or URL '{$filename}' does not exist.");
        }

        return $lines;
    }
protected function fileOrUrl($filename)
    {
        $options = array();
        if (!empty($this->httpBasicAuth) || !empty($this->httpUserAgent)) {
            $options['http'] = array();
            $options['http']['header'] = array();

            if (!empty($this->httpBasicAuth)) {
                $username  = $this->httpBasicAuth['username'];
                $password  = $this->httpBasicAuth['password'];
                $basicAuth = base64_encode("{$username}:{$password}");

                array_push($options['http']['header'], "Authorization: Basic {$basicAuth}");
            }

            if (!empty($this->httpUserAgent)) {
                array_push($options['http']['header'], "User-Agent: {$this->httpUserAgent}");
            }
        }

        $context = stream_context_create($options);

        if (($lines = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES, $context)) === false) {
            throw new \Exception("The file path or URL '{$filename}' does not exist.");
        }

        return $lines;
    }
protected function fileOrUrl ( $ filename ) { $ options = array ( ) ; if ( ! empty ( $ this -> httpBasicAuth ) || ! empty ( $ this -> httpUserAgent ) ) { $ options [ 'http' ] = array ( ) ; $ options [ 'http' ] [ 'header' ] = array ( ) ; if ( ! empty ( $ this -> httpBasicAuth ) ) { $ username = $ this -> httpBasicAuth [ 'username' ] ; $ password = $ this -> httpBasicAuth [ 'password' ] ; $ basicAuth = base64_encode ( "{$username}:{$password}" ) ; array_push ( $ options [ 'http' ] [ 'header' ] , "Authorization: Basic {$basicAuth}" ) ; } if ( ! empty ( $ this -> httpUserAgent ) ) { array_push ( $ options [ 'http' ] [ 'header' ] , "User-Agent: {$this->httpUserAgent}" ) ; } } $ context = stream_context_create ( $ options ) ; if ( ( $ lines = file ( $ filename , FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES , $ context ) ) === false ) { throw new \ Exception ( "The file path or URL '{$filename}' does not exist." ) ; } return $ lines ; }
Reads an entire file or URL into an array

@param  string $filename
@return array
@throws \Exception
Reads an entire file or URL into an array