Php – How to get the byte values of a string in PHP


Say I have a string in php, that prints out to a text file like this:


How do I get the byte codes of this to my text file rather than the funky ascii characters?

Best Solution

Use the ord function


$var = "nÖ§9q1Fª£ˆæÓ§Œ_»—Ló]j";

for($i = 0; $i < strlen($var); $i++)
   echo ord($var[$i])."<br/>";