I’m trying to do a “preg match all” on the response below to get all the binary data. I’ve tried just about everything imaginable and for the life of me, can’t get anything.
I was hoping it’d be as simple as doing something like this:
preg_match_all("#\n\n(.*)\n--$boundary#",$body,$matches);
But I can’t get anything. I’ve tried other stuff too. \r \n | i s m U – I just can’t get it for some reason.
Here is a pseudo response not including the headers:
--boundary
content-type:image/jpeg
<binary data>
--boundary
content-type:image/jpeg
<binary data>
--boundary
content-type:image/jpeg
<binary data>
--boundary
unfortunately the binary data isn’t enclosed with < & > it’s just raw data with special characters over the course of multiple lines…
also: i think the problem lies within the actual binary data that is being displayed because when i run a preg match all on the info above it works just fine but when i try it on the actual data that has all the binary data crap in it, it doesn’t work.
Alternatively, you could parse with explode() this should be much faster, it’s not too complex, and it gives you the header info if you want it: