How to convert a string to ASCII value in PHP without ord()?
问题 I am looking to convert a string say 'Hello' world to its ASCII value in php. But I don't want to use ord() . Are there any other solutions for printing ascii value without using ord() ? 回答1: unpack() Unpacks from a binary string into an array according to the given format. Use the format C* to return everything as what you'd get from ord() . print_r(unpack("C*", "Hello world")); Array ( [1] => 72 [2] => 101 [3] => 108 [4] => 108 [5] => 111 [6] => 32 [7] => 119 [8] => 111 [9] => 114 [10] =>