Take the contents of the text file on codeigniter

I intend to take the contents of a txt file, I'm using the Codeigniter framework. I put the content of url.txt in the root folder.

$link_univ = 'http://localhost/perpus3/index.php/webService/wsdl';
$link_mipa = 'http://localhost/perpus_mipa/index.php/webService/wsdl';

In folder controllers I'm having Koleksi.php and I create a function to take the contents of url.txt

$lines = file('url.txt');
foreach ($lines as $line_num => $line){
    print $line. "<br />\n"; 
}

Upvotes: 0

Views: 3108

Answers (1)

Xylude Xaalud
Xylude Xaalud

Reputation: 510

You should check out the file helper. It will do all that for you. Example:

$this->load->helper('file');
$string = read_file('./path/to/file.php');

now the $string variable should have the text from file.php.

Upvotes: 1

Related Questions