note 34297 added to function.bin2hex
| From: | (ffaria@mutua.com.br) | Date: | Mon, 21 Jul 2003 21:33:11 +0000 |
| Subject: | note 34297 added to function.bin2hex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52465@lists.php.net to get a copy of this message | ||
function to search a character in a normal string change this for a hexadecimal and take the
especifical char code in hexa and replace this char and return the string
function hex_replace($pCaracter,$sCaracter,$conteudo) {
$pHex = bin2hex($pCaracter);
$sHex = bin2hex($sCaracter);
$tam = strlen($conteudo);
for($i = 0; $i <= $tam; $i++) {
$cont = bin2hex(substr($conteudo,$i,1));
if ($cont == $pHex) {
$cont = $sHex;
$hex .= $cont;
}
}
for ($i=0;$i<strlen($hex);$i+=2)
$bin .= chr(hexdec(substr($hex,$i,2)));
return $bin;
}
by from a litle brazilian. :-P
----
Manual Page -- http://www.php.net/manual/en/function.bin2hex.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34297
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34297&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34297&report=yes