Re: filter records... how?

From: Date: Tue, 27 Aug 2002 23:07:19 +0000
Subject: Re: filter records... how?
Groups: php.general 
Request: Send a blank email to php-general+get-114297@lists.php.net to get a copy of this message
>I have this set of code. and what I want to know how to do is how to >filter one or more vars in the flat file? For example filter all the >people that work "at night" Honestly, you'd be best off moving the data into a database (MySQL or otherwise)... At this point, you're starting to do a lot of work that's already been done by somebody else... >I'm assuming it has to be in this part of the code: >for($i = 0; $i < count($arr_lines); $i++) >{ > $arr_data = explode($delim, $arr_lines[$i]); $worksdelim = $arr_data[1]; echo "Works is '$worksdelim'<BR>\n"; if ($worksdelim == 'at night'){ # Or something like 'at night'... > print $arr_data[0].' '.$arr_data[1].' > '.$arr_data[2].'<BR>'; } >} > >But where do I add an IF statement if that is what is needed? > ><?php > >/*assigned vars*/ >$delim = "\t"; >$file_path = "newfile.dat"; > >$name = "matt"; >$works = "at night"; >$programs = "php"; > >/*exporting data to flat file*/ >$file = fopen($file_path, "a"); >fwrite($file, $name.$delim); >fwrite($file, $works.$delim); >fwrite($file, $programs); >fwrite($file, "\n"); >fclose($file); > >$file = fopen($file_path,"r"); >$page = fread($file, 4950); > >$arr_lines = explode("\n", $page); >for($i = 0; $i < count($arr_lines); $i++) >{ > $arr_data = explode($delim, $arr_lines[$i]); > print $arr_data[0].' '.$arr_data[1].' > '.$arr_data[2].'<BR>'; >} > >fclose($file); > >?> > >TIA! > >-Matt > > > >-- >Matt Zur >mattz@zurnet.com >http://www.zurnet.com > >Need a Web Site??? - Visit... www.zurnet.com > >1997 - 2002 - 5th Anniversary!!! > -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#114297) next »