klsfriend Posted June 16, 2008 Share Posted June 16, 2008 I have some code and I'm trying to figure out how to manipulate the array results. The code takes a text file as input. The text file is essentially a set of "records" with each "field" a separate line designated by an initial letter. For example: abob b12345 [email protected] ajim b54321 [email protected] I am using an array to gather the content. The way I have it the array gets the correct lines and it prints out fine but still in the bline cline format. I would like to be able to have it print out with the line, then a delimiter, then the second line such as bline:cline bline:cline etc. Any help would be greatly appreciated. Here is the code I'm using. $lines_to_fetch = array('b','c'); $inputfile = fopen("filename", "r"); if ($inputfile) { while (!feof($inputfile)) { $linedesignator = fread($inputfile, 1); $content = fgets($inputfile); $contentlower = strtolower($content); if (in_array($linedesignator,$lines_to_fetch)) { echo $contentlower; } } fclose($inputfile); Quote Link to comment https://forums.phpfreaks.com/topic/110364-manipulating-array-content/ Share on other sites More sharing options...
Barand Posted June 16, 2008 Share Posted June 16, 2008 Must be a homework assignment. No one in the real world would come up with an input format like that. Quote Link to comment https://forums.phpfreaks.com/topic/110364-manipulating-array-content/#findComment-566253 Share on other sites More sharing options...
klsfriend Posted June 16, 2008 Author Share Posted June 16, 2008 Actually it is NOT a "homework" assignment but a real world issue at a major university and not an uncommon input format at all. Thanks for the attitude. Hopefully there are some REAL experts out there that can provide some insight. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/110364-manipulating-array-content/#findComment-566697 Share on other sites More sharing options...
.josh Posted June 16, 2008 Share Posted June 16, 2008 Actually it is NOT a "homework" assignment but a real world issue at a major university and not an uncommon input format at all. Thanks for the attitude. Hopefully there are some REAL experts out there that can provide some insight. Thanks in advance. LOL. Seriously, what kind of major university would have real world coding like that? Quote Link to comment https://forums.phpfreaks.com/topic/110364-manipulating-array-content/#findComment-566722 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.