PHP implements binary and text to convert each other method,
In this paper, we describe the method of translating PHP into binary and text. Share to everyone for your reference. Specific as follows:
This code contains two functions, bin2text, binary conversion to text, Text2bin, text into binary
<?phpfunction Bin2text ($bin _str) {$text _str = '; $chars = explode ("\ n", Chunk_split (Str_replace ("\ n", "", $bin _str), 8)); $_i = count ($chars); for ($i = 0; $i < $_i; $text _str. = Chr (Bindec ($chars [$i])), $i); return $text _str;} function Text2bin ($txt _str) {$len = strlen ($txt _str); $bin = "; for ($i = 0; $i < $len; $i) { $bin. = strlen (DECBI N (Ord ($txt _str[$i])) <8?str_pad (Decbin (Ord ($txt _str[$i)), 8,0,str_pad_left):d Ecbin (Ord ($txt _str[$i])); } return $bin;} Print Text2bin (' How is you gentlements? ');? >
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/986075.html www.bkjia.com true http://www.bkjia.com/PHPjc/986075.html techarticle PHP Implementation of binary and text to convert the method, this article describes the implementation of PHP binary and text conversion method. Share to everyone for your reference. As follows: This period of ...