Greetings All!

Once again I find myself trying to figure out the proper preg syntax.

Today my problem is that I have a file that has several lines with $boundary in it.

The trouble is, sometimes the program that creates this file sticks a couple of extra characters on the same line... before and/or after the text that makes up $boundary.

What I need to do is to chop the file apart wherever that line occurs.

My most recent attempt has been:

$chunks=preg_split("/.$boundary.$/",$whole_thing);

Where $whole_thing is the multi-line string of text. Like I said, my goal here was to say "chop wherever you see a line with $boundary somewhere in it".

What's the correct syntax ?

Thanks!

-= Dave =-

    Isn't this straight forward enough?

    $chunks=preg_split("/$boundary/",$whole_thing);

      Nope, that wasn't working.

      Here's what DID end up working:

      $chunks=preg_split("/(.*)$boundary/m",$whole_thing);

      Apparently, I needed that "/m" in order to get the beginning of a single line instead of the beginning of the entire string. At least that's what I got out of the pages and pages of tutorials I poured over.

      I discovered this and then went to bed for the night. Sorry I didn't come back and post the solution here. Just woke up.

      Thanks!

      -= Dave =-

        Write a Reply...