Can anyone help me with this?
I have an string and it has strings like this:
{i:xxxx} where xxxx is an hexadecimal number , I need to trasform this into something like this:
&#X; where X is the decimal conversion of xxxx
I am currently using something like this , but it does not work:
$string=preg_replace( "{i:([0-9A-F]{4})}",chr(38).chr(35).hexdec("$1").chr(59),$string);
for an string like this {i:F991}, it returns :
{} and I want to return 撚
63889 is the hexadecimal conversion of F981
I really appreciate any help :lol:
preg_replace function
Moderator: General Moderators
Code: Select all
$string="{i:F991}";
$string=preg_replace("/{i:(ї0-9A-F]{4})}/e","chr(38).chr(35).hexdec("\\1").chr(59)",$string);
echo $string."\n";