chaosxkitten Posted February 5, 2011 Share Posted February 5, 2011 This is the function I wrote function getParagraph($myfile) { while (!feof($myfile)){ $data = fgets($myfile); $paragraph = explode("\n", $data); } return $paragraph; } When I print the array, it's empty. while ($paragraph = getParagraph($file)){ print_r($paragraph); } Prints to my webpage as: Array ( [0] => ) The file is NOT empty, and it is formated by line breaks so I don't know what's not working. Link to comment https://forums.phpfreaks.com/topic/226801-function-not-working/ Share on other sites More sharing options...
kenrbnsn Posted February 5, 2011 Share Posted February 5, 2011 What is the value of the variable "$file"? Ken Link to comment https://forums.phpfreaks.com/topic/226801-function-not-working/#findComment-1170332 Share on other sites More sharing options...
chaosxkitten Posted February 5, 2011 Author Share Posted February 5, 2011 It's a file handle for a text file containing the constitution broken up into paragraphs by line breaks. Link to comment https://forums.phpfreaks.com/topic/226801-function-not-working/#findComment-1170334 Share on other sites More sharing options...
kenrbnsn Posted February 5, 2011 Share Posted February 5, 2011 Why don't you just use the file function? Ken Link to comment https://forums.phpfreaks.com/topic/226801-function-not-working/#findComment-1170348 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.