Jump to content

preg_match help


treeleaf20

Recommended Posts

All,

I have the following data:

 

Content-Disposition: attachment; filename="psu_logo.jpg"

Content-Transfer-Encoding: base64

X-Attachment-Id: f_g0r43rin0

 

/9j/4AAQSkZJRgABAgEASABIAAD/4ROrRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUA

AAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAcAAAAcgEyAAIAAAAUAAAAjodp

AAQAAAABAAAApAAAANAACvyAAAAnEAAK/IAAACcQQWRvYmUgUGhvdG9zaG9wIENTMiBXaW5kb3dz

ADIwMDg6MTI6MTEgMTE6Mzg6MzAAAAAAA6ABAAMAAAAB//8AAKACAAQAAAABAAABLKADAAQAAAAB

AAAAyAAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEA

AgAAAgEABAAAAAEAAAEuAgIABAAAAAEAABJ1AAAAAAAAAEgAAAABAAAASAAAAAH/2P/gABBKRklG

 

I tried to write the following regular expression:

$filetype2 = array();
if (preg_match('/X-Attachment-Id:(.*)/', $data, $filetype2))
{
for($x=0;$x<6;$x++){
$filetypeuse = $filetype2[$x];
echo "<br><br>The filetypeuser2 is $filetypeuse[$x]";
}
} 

The output is:

The filetypeuser2 is X-Attachment-Id: f_g0r43rin0

 

The filetypeuser2 is f_g0r43rin0

 

The filetypeuser2 is

 

The filetypeuser2 is

 

The filetypeuser2 is

 

The filetypeuser2 is

 

How can I get the rest of the data? Thanks.

 

Link to comment
Share on other sites

if (preg_match('/X-Attachment-Id:(.*)/', $data, $filetype2))

should be

if (preg_match('/X-Attachment-Id:(.*)/s', $data, $filetype2))

 

s = dot matches new lines

 

EDIT: however i must point out that the data "/9j/4AAQ..." will be captured in the first loop, but i'm not sure what "the rest of that data" truly refers to

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.