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. Quote 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 Quote 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); Quote Link to comment https://forums.phpfreaks.com/topic/177610-preg_match-help/#findComment-936485 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.