Hex file data. How to evaluate it?

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
garyshall
Forum Newbie
Posts: 1
Joined: Sat Jul 19, 2003 7:05 pm

Hex file data. How to evaluate it?

Post by garyshall »

Having trouble parsing a file and checking for a particular hexadecimal value. Somebody help me out here.

$fp = fopen($file,"rb+");
$char = fgetc($fp);

if ($char == 0x4d)
{
echo "found it! ";
}

The first byte of this file is 4d hex, or "M" ASCII. This code won't find it. If I change to:

if ($char == "M")

Then is does trap the byte. What am I doing wrong? :cry:
Post Reply