How do I change integer string to hex in php?

I'm a beginner at php so please forgive me if this seems like a noobish question. I've been reading tutorials and the php manual but I can figure this out.
How do I take a variable with an integer string data and output it as the hex character?
for example
<?php
$data = "65";
$the_e = "\x".$data;
echo $the_e;
?>
outputs the string "\x65" when I want the character 'e'. Is there a simple way to do this I've been looking for a work-around but I need to have the hexcode from a variable or I'd need a switch statement that handles each byte.
<?php
$data = $_POST[variable];
switch($data){
case "00":
echo "\x00";
break;
case "01":
echo "\x01";
break;
ect...
?>
I'd really rather not do that for obvious reasons. If anybody know how to do this or has a better work-around please let me know, thanks.

Frxstrem2010-06-10T07:31:41Z

Favorite Answer

There are two PHP functions that does conversion between integers and characters:

<?php
$char = "e";
$int = 65;

$char == chr($int); # true, as chr(65) is 'e'
$int == ord($char); # true, as ord('e') is 65
?>

So, to summarize, chr() converts and integer to a character and ord() does the opposite.