This really does not have much a purpose other then to amuse my self and anyone else thats intrested, its 2 functionsto convert ascii text to binary and binary back to ascii, have you ever seen this page http://nickciske.com/tools/binary.php? its been featured on The Screen Savers, and after i saw it i always wondered how it was done, well this is how. It's nothing too special but leave your comments and please vote, i'd like to know what everyone thinks, thanks
Terms of Agreement:
By using this article, you agree to the following terms...
You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
You may link to this article from another website, but ONLY if it is not wrapped in a frame.
You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
to convert ascii text use this function
function asc2bin($in)#syntax - asc2bin("text to convert");
{
$out = '';
for ($i = 0, $len = strlen($in); $i < $len; $i++)
{
$out .= sprintf("%08b",ord($in{$i}));
}
return $out;
}
use this function to convert binary back to readable ascii text
function bin2asc($in)#syntax - bin2asc("binary to convert");
{
$out = '';
for ($i = 0, $len = strlen($in); $i < $len; $i += 8)
{
$out .= chr(bindec(substr($in,$i,8)));
}
return $out;
}
have fun with it and please give credit if you use these functions :)
Ryan Cheeseman
~~Dull1554
~~~~Dull1554@gmail.com
Itz d best site i hv visited (If this comment was disrespectful, please report it.)
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular article, please
click here instead.)