for($i=0; $i < strlen($text); $i++)
{
print("
print("
if(ord($text[$i]) > 31)
{
print($text[$i]);
}
else
{
print("(unprintable)");
}
print("
print(ord($text[$i]));
print("");
print("
}
print("\n");
?>
string pack(string format, ...)
The pack function takes inspiration from the Perl function of the same name. It allows
you to put data in a compact format readable on all platforms. Format codes in the first
argument match with the arguments that follow it. The codes determine how the values
are stored. An optional number, called the repeat count, may follow the format code. It
specifies how many of the following arguments to use. The repeat count may also be *,
which matches the remaining arguments. Some of the codes use the repeat count
differently. Table 9.6 lists all the format codes and how they use the repeat count.
A string with the packed data is returned. Note that it will be in a
binary form, unsuitable for printing. In the example below, I've printed
out each byte of the packed data as hexadecimal codes.
<?
//create some packed data
$packedData = pack("ca10n", 65, "hello", 1970);
//display ASCII code for each character
print("
");