Bueno... leyendo un poco en php.net me encontré con esta función que trata al código distinto... basándose en la función file(). Es llamada file_v2() y fue creada por Cory Christison:
Código PHP:
/*The file function will load the entire file before you can do anything to it [remove lines, explode() each line, and so on...]
I wrote a function [ file_v2() ] to help eliminate the restrictions of file(). Below are a few features/abilites file_v2() has over file().
file_v2() features:
- uses an editable buffer size, for performance tweaking.
- ability set maximum lines returned[from beginning]
- optional automatically rtrim the line
- optional ability to provide a callback function for each array element
Here is the code:*/
function file_v2($filename, $return_max_lines=500, $callback_func=null, $do_rtrim=true, $buffer_size=1024){
// open file pointer
$open=fopen($filename, 'rb');
// start an array
$open_data=array();
// start an internal line counter
$line=0;
// begin the loop
while(!feof($open)){
if($do_rtrim){
// add line to array, do an rtrim()
$open_data[$line]=rtrim(fgets($open, $buffer_size));
}else{
// add line to array
$open_data[$line]=fgets($open, $buffer_size);
}
if($callback_func!=null && function_exists($callback_func)){
eval($callback_func . '($open_data[$line]);');
}
// +1 to the internal line counter
$line++;
if($return_max_lines>0){
if($line >= $return_max_lines){
break;
}
}
}
// close the file pointer
fclose($open);
// return the data
return $open_data;
}
Sin embargo, después de usarla sigue sin reconocerme el código PHP que se encuentre dentro del archivo. ¿Qué puedo hacer para que sea interpretado el código que se encuentre dentro del archivo que estoy abriendo?