Page 1 of 1

comparing hex values comprising string

Posted: Mon Apr 25, 2005 3:49 am
by jasongr
Hello

I have a string which I read from a file
I would like to test if the string begins with a specific hex prefix like so:
FF D8 FF E0
the value read from the file is found in a variable called $input
How can I make such comparison?

regards

Posted: Mon Apr 25, 2005 8:21 am
by n00b Saibot

Code: Select all

if (preg_match(&quote;#^FF D8 FF E0#&quote;,$input))
 //then do whatever

Posted: Mon Apr 25, 2005 5:27 pm
by R0d Longfella
use sscanf, or an equivalent function to read out hex values, check the php manual. Goodluck R0d