note 47663 added to function.bin2hex

From: Date: Wed, 24 Nov 2004 13:11:34 +0000
Subject: note 47663 added to function.bin2hex
Groups: php.notes 
Request: Send a blank email to php-notes+get-80970@lists.php.net to get a copy of this message
A good option for creating strings with binary data for saving (for example saving an sql statement to a file) into text files or php code is to do the following: <?php $field=bin2hex($field); $field=chunk_split($field,2,"\\x"); $field= "\\x" . substr($field,0,-2); ?> this will convert your field (binary or not) into hex and then convert the hex into a string which may be placed in a php file: FFFFFFFF -> \xFF\xFF\xFF\xFF ---- Manual Page -- http://www.php.net/manual/en/function.bin2hex.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47663 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47663&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47663&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47663&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47663&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47663&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47663&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47663&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80970) next »