+ 114
Convert HEX to string in PHP
Hi, friends. I need help PHP. How a variable type HEX var=0x31002300330006; to convert to string var_str='31002300330006';
5 Respuestas
+ 8
$hexNum = 0x64;
$str = dechex($hexNum);
(Edited)
+ 57
But what if the MS SQL database is a large field, not a number, for example "binary(100)"
0x746D696E3D30303A30303A333000746D696E3D30303A30303A333000
+ 5
Then PHP cannot hold it as an accurate number, so calculation will be hard. Maybe you should not save that long number, or you can write your own algorithm. Another suggestion, is to save that long number as a string, and then make operations on it. But I think in a 64bit OS, you can only save a number as integer up to 2**64 - 1, not just about PHP.
EDIT: However, there are extensions or libraries that can handle bigger numbers.
+ 5
можно средствами Ms Sql -
declare @hexstring varchar(max); set @hexstring = '0xabcedf012439'; select CONVERT(varbinary(max), @hexstring, 1);
+ 4
I've edited my answer. This would be the true answer!