Skip to content
Advertisement

How to convert text to x codes?

I want to convert normal text to x codes for e.g x14x65x60

For example :

normal text = "base64_decode"
converted x codes for above text = "x62141x73145x3664x5f144x65143x6f144x65"

How to do this? Thanks in advance.

Advertisement

Answer

PHP 5.3 one-liner:

echo preg_replace_callback("/./", function($matched) {
    return 'x'.dechex(ord($matched[0]));
}, 'base64_decode');

Outputs x62x61x73x65x36x34x5fx64x65x63x6fx64x65

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement