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??

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.