★ wanayoo — archive 1999 http://www.php.net/manual/function.bin2hex.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Strings
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
Strings
* AddCSlashes
* AddSlashes
* bin2hex
* Chop
* Chr
* chunk_split
* convert_cyr_string
* count_chars
* crc32
* crypt
* echo
* explode
* flush
* get_html_translation_table
* get_meta_tags
* hebrev
* hebrevc
* htmlentities
* htmlspecialchars
* implode
* join
* levenshtein
* ltrim
* md5
* Metaphone
* nl2br
* ob_start
* ob_get_contents
* ob_end_flush
* ob_end_clean
* ob_implicit_flush
* Ord
* parse_str
* print
* printf
* quoted_printable_decode
* quotemeta
* rtrim
* sscanf
* setlocale
* similar_text
* soundex
* sprintf
* strcasecmp
* strchr
* strcmp
* strcspn
* strip_tags
* stripcslashes
* stripslashes
* stristr
* strlen
* str_pad
* strpos
* strrchr
* str_repeat
* strrev
* strrpos
* strspn
* strstr
* strtok
* strtolower
* strtoupper
* str_replace
* strtr
* substr
* substr_count
* substr_replace
* trim
* ucfirst
* ucwords
Manual: bin2hex
View the source code for this pageSearch the site



Previous page
 AddSlashes
 Updated
Sat, 12 Aug 2000
Chop 
Next page


bin2hex

(PHP3 >= 3.0.9, PHP4 )

bin2hex --  Convert binary data into hexadecimal representation

Description

string bin2hex (string str)

Returns an ASCII string containing the hexadecimal representation of str. The conversion is done byte-wise with the high-nibble first.


User Contributed Notes: bin2hex


josh@superfork.com
22-Jun-1999 05:56
I wrote a short function to convert the hex string back to binary.


function hex2bin($data) {

$len = strlen($data);
for($i=0;$i<$len;$i+=2) {
$newdata .= pack("C",hexdec(substr($data,$i,2)));
}
return $newdata;
}



carl@five-ten-sg.com
11-Aug-1999 12:50


function hex2bin($data) {

$len = strlen($data);

return pack("H" . $len, $data);

}



lulu@ctyd.com.mx
14-Dec-1999 08:12
Another one:

function hex2bin($hex_data){

return (DecBin(HexDec($hex_data));

}



dimitry@career.ru
17-Jan-2000 06:55
echo bin2hex("abc");

Output is:
616263



 About Notes


Previous page
 AddSlashes
 Updated
Sat, 12 Aug 2000
Chop 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.