How do I convert an integer to ascii?
Like I have $test = 0x55. How do I get $test_string = "T"?
[SOLVED] Int -> String HELP HELP
Moderator: General Moderators
0x55 is the letter U by the way
Code: Select all
<?php
$test = 0x55;
echo chr($test);
?>okay, maybe 0x23 was a bad example, but I want the number can be anything from 0x00 to 0xFF. But chr($test) is showing all those as 0x00.
Here is the code
feyd | flipped
Here is the code
Code: Select all
function describe()
{
global $text;
global $text_descriptor;
global $text_length;
global $start;
$text_raw = array_values(unpack('C*', $text));
$text_raw .= " ";
$text_raw = substr($text_raw, 0, ;
$start = 0;
for ($i = 0; $i < 8; $i++)
{
$temp = $text_raw[$i] & 0x01;
$start = $start | ($temp << $i);
$text_descriptor[$i] = 0;
echo (pack('N*', $text_descriptor[$i])."<br>");
for ($j = 0; $j < 8; $j++)
{
if ($j < 7)
{
if (($text_raw[$i] & (1 << $j)) == (($text_raw[$i] & (1 << ($j + 1))) >> 1))
{
}
else
{
$text_descriptor[$i] |= 1 << ($j);
}
}
else
{
if (($text_raw[$i] & 0x01) == (($text_raw[$i] & 0x80) >> 7))
{
}
else
{
$text_descriptor[$i] |= 1 << ($j);
}
}
}
}
$ret_string = chr($start);
echo ("Start -> ".$ret_string." <br>");
for ($i = 0; $i < $text_length; $i++)
{
$ret_string = $ret_string.chr($text_descriptor[$i]);
echo ($ret_string."<br>");
}
return $ret_string;
}feyd | flipped
Code: Select all
toCode: Select all
[/color]