On Wed, May 16, 2001 at 05:13:16PM -0400, jtjohnston wrote:
> I am parsing the contents of a text file.
Congratualtions.

> I have certain lines that start with "&&4;" I would like to attach these
> lines to the previous line as follows. But I don't know how. I figure I
> have to search and replace for "\n&&4;" but ... ?

You could try something like this:

<?php
$file = file("file");
for($i = 0, $k = 0; $i < sizeof($file); $i++) {
   if(substr($file[$i], 0, 4) == "&&4;") {
      $newfile[$k - 1] .= $file[$i];
   }
   else {
      $newfile[$k++] = $file[$i];
   }
}
?>

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
Perl programming is an *empirical* science!
             -- Larry Wall in <[EMAIL PROTECTED]>

-- 
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]

Reply via email to