php的字符串到字节集示例。

$str = 'hello word';
$arr = array();
for($i=0;$i<strlen($str);$i++){
$arr[] = ord($str{$i});
}
print_r($arr);
输出:
Array
(
[0] => 104
[1] => 101
[2] => 108
[3] => 108
[4] => 111
[5] => 32
[6] => 119
[7] => 111
[8] => 114
[9] => 100
)

Related Posts: PHP-字符串到字节集 :