comparing hex values comprising string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

comparing hex values comprising string

Post 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
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Code: Select all

if (preg_match(&quote;#^FF D8 FF E0#&quote;,$input))
 //then do whatever
R0d Longfella
Forum Newbie
Posts: 20
Joined: Fri Apr 08, 2005 7:17 am

Post by R0d Longfella »

use sscanf, or an equivalent function to read out hex values, check the php manual. Goodluck R0d
Post Reply