Nick Richardson wrote: > > ... > > Example: I want to pass a string using the URL (blah.php?car=civic_si) then > search for ##civic_si in the text file, and print everything until it finds > ##end. So the text file will look like this: > > ##civic_si > This is my content, blah blah > ##end > > ##nissan > This is more content... yadda yadda > ##end > > ... >
Try this little code snippet: <? $filename = 'cars.data'; $car = $HTTP_GET_VARS['car']; if ($car != '') { $file = file($filename); if (is_array($file)) { $read = FALSE; foreach ($file as $f) { if (!$read && ereg('^##'.$car, $f)) $read = TRUE; elseif ($read && ereg('^##end', $f)) { $read = FALSE; break; } elseif ($read) $content .= $f; } } } echo "content=$content<br>"; ?> Hope this helps. :) -- Pavel a.k.a. Papi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]