0

hi all,

well sory for my bad question, its my bad. by the way thanks for your replied but it seems still have a problem. my only main goal is creat a function read a file. and I have this function to read the file. but I got an error message.

here is my error message.

Warning: file() expects parameter 1 to be string, array given in
Warning: Invalid argument supplied for foreach() in
Fatal error: Function name must be a string in.

and i have this code to read the file.

function processFile($filename) {
          $lines = file($filename);
             $returnArray= Array();
            foreach ($lines as $line) {
            $returnArray[]='<tr><td>Title:</td><td>'.($output[0]).'</td><td>Value:</td><td>'.$output[1].'</td></tr>';
            }      
             return $returnArray();
         }

and this my test page.

       require_once('chadlib.php');
      $string = file('test.php');
         $strings=processFile($string);
         echo '<table>';
            foreach ($strings as $element => $value)
         echo '<p>'.$value.'</p>
';
         echo '</table>';

Have another Idea where did I got wrong, Im newbie in php??

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by nav33n
0

$string = file('test.php');
$strings=processFile($string);

file() returns an array. So, $string will be an array. You are supposed to send the filename!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.