treeleaf20 Posted October 13, 2009 Share Posted October 13, 2009 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 More sharing options...
MadTechie Posted October 13, 2009 Share Posted October 13, 2009 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 More sharing options...
JAY6390 Posted October 14, 2009 Share Posted October 14, 2009 preg_match('/^X-Attachment-Id: (.*?)$/m', $data, $filetype2); Link to comment https://forums.phpfreaks.com/topic/177610-preg_match-help/#findComment-936485 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.