How to convert text to \x codes?

后端 未结 6 1485
别跟我提以往
别跟我提以往 2021-01-06 02:27

I want to convert normal text to \\x codes for e.g \\x14\\x65\\x60

For example :

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


        
6条回答
  •  一整个雨季
    2021-01-06 02:57

    Here's working code:

    function make_hexcodes($text) {
        $retval = '';
        for($i = 0; $i < strlen($text); ++$i) {
            $retval .= '\x'.dechex(ord($text[$i]));
        }
    
        return $retval;
    }
    
    echo make_hexcodes('base64_decode');
    

    See it in action.

提交回复
热议问题