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 259 views
1 answer 216 views
1 answer 316 views
1 answer 336 views
1 answer 241 views
1 answer 270 views
...