gudfry Posted July 24, 2008 Share Posted July 24, 2008 hi all; I have a recursive function the read the file, but its doesn work properly so It a big problem for me as a newbie in php, i need help to someone, here is my function that read the file and returning the line of file as array of string. function processFile($filename) { $lines = file($filename); $returnArray= array(); foreach ($lines as $line) { $output=processFile($string); if (gettype($output)=="array") { $returnArray[]='<tr><td>Title:</td><td>'.($output[0]).'</td><td>Value:</td><td>'.$output[1].'</td></tr>'; } } return $returnArray; } I have another page to test the my function if it running but this is the way i got the error. Warning: file() expects parameter 1 to be string, array given in F:\ Warning: Invalid argument supplied for foreach() in F require_once('chadlib.php'); $string = file('test.php'); $strings=processFile($string); echo '<table>'; foreach ($strings as $element => $value) { echo $value; echo '</table>'; } please check theline of my code. thank in advance. Link to comment https://forums.phpfreaks.com/topic/116370-please-check-the-line-of-my-function/ Share on other sites More sharing options...
MasterACE14 Posted July 24, 2008 Share Posted July 24, 2008 try change it to this... function processFile($filename) { $lines = file($filename); $returnArray= array(); foreach ($lines as $line) { $output=processFile($string); if (gettype($output)=="array") { $return = '<tr><td>Title:</td><td>'.($output[0]).'</td><td>Value:</td><td>'.$output[1].'</td></tr>'; } } return $return; } Link to comment https://forums.phpfreaks.com/topic/116370-please-check-the-line-of-my-function/#findComment-598384 Share on other sites More sharing options...
gudfry Posted July 24, 2008 Author Share Posted July 24, 2008 ows hi; thanks for the replied, but its sad to say that i still got tdesame error, Link to comment https://forums.phpfreaks.com/topic/116370-please-check-the-line-of-my-function/#findComment-598388 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.