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 248 views
1 answer 207 views
1 answer 299 views
1 answer 314 views
1 answer 232 views
1 answer 258 views
...