How to use file() function to read entire file into an array in PHP

1 Answer

0 votes
$content = file('c:/xampp/htdocs/knowrex.com/index.php');
   
foreach ($content as $line_num => $line) 
{
    echo "Line {$line_num} : " . htmlspecialchars($line);
    echo "<br />\n";
}

/*
run: 

Line 0 : <?php
Line 1 :
Line 2 : include_once "config/global.php"; 

...                                                                   

*/

 



answered Apr 21, 2016 by avibootz

Related questions

2 answers 241 views
1 answer 203 views
1 answer 291 views
1 answer 303 views
1 answer 226 views
1 answer 253 views
...