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
https://forums.phpfreaks.com/topic/177610-preg_match-help/
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
https://forums.phpfreaks.com/topic/177610-preg_match-help/#findComment-936462
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.