note 127517 added to function.hex2bin

From: Date: Sun, 21 Aug 2022 11:54:27 +0000
Subject: note 127517 added to function.hex2bin
Groups: php.notes 
Request: Send a blank email to php-notes+get-219457@lists.php.net to get a copy of this message
#error: hex2bin(): Hexadecimal input string must have an even length For those who are facing the error above trying to convert hex to bin. you can pad your hex string with initial 0 before hex2bin. function hexPad(string $hex_string) { $st_l = strlen($hex_string); return str_pad($hex_string, $st_l + ($st_l % 2), '0', STR_PAD_LEFT); } hexPad('1bc') -> '01bc'; for usage hex2bin(hexPad('1bc')); ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.175 (proxied: 41.217.66.236) ---- Manual Page -- https://php.net/manual/en/function.hex2bin.php Edit -- https://main.php.net/note/edit/127517 Del: integrated -- https://main.php.net/note/delete/127517/integrated Del: useless -- https://main.php.net/note/delete/127517/useless Del: bad code -- https://main.php.net/note/delete/127517/bad+code Del: spam -- https://main.php.net/note/delete/127517/spam Del: non-english -- https://main.php.net/note/delete/127517/non-english Del: in docs -- https://main.php.net/note/delete/127517/in+docs Del: other reasons-- https://main.php.net/note/delete/127517 Reject -- https://main.php.net/note/reject/127517 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#219457) next »