note 127334 added to function.dechex
| From: | mahdiyari at main dot php dot net | Date: | Sun, 24 Jul 2022 11:45:11 +0000 |
| Subject: | note 127334 added to function.dechex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219056@lists.php.net to get a copy of this message | ||
Zero padded hex strings as a pair of 2 (8bit).
<?php
function dec2hex($int) {
$hex = dechex($int);
if (strlen($hex)%2 != 0) {
$hex = str_pad($hex, strlen($hex) + 1, '0', STR_PAD_LEFT);
}
return $hex;
}
dec2hex(2); // 02
dec2hex(10); // 0a
dec2hex(256); // 0100
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.135 (proxied: 92.119.59.171)
----
Manual Page -- https://php.net/manual/en/function.dechex.php
Edit -- https://main.php.net/note/edit/127334
Del: integrated -- https://main.php.net/note/delete/127334/integrated
Del: useless -- https://main.php.net/note/delete/127334/useless
Del: bad code -- https://main.php.net/note/delete/127334/bad+code
Del: spam -- https://main.php.net/note/delete/127334/spam
Del: non-english -- https://main.php.net/note/delete/127334/non-english
Del: in docs -- https://main.php.net/note/delete/127334/in+docs
Del: other reasons-- https://main.php.net/note/delete/127334
Reject -- https://main.php.net/note/reject/127334
Search -- https://main.php.net/manage/user-notes.php