Int -> String HELP HELP
Posted: Mon Aug 02, 2004 11:57 pm
How do I convert an integer to ascii?
Like I have $test = 0x55. How do I get $test_string = "T"?
Like I have $test = 0x55. How do I get $test_string = "T"?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
$test = 0x55;
echo chr($test);
?>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;
}Code: Select all
toCode: Select all
[/color]