php equivalent of java getBytes() [duplicate]
Possible Duplicate:
String to byte array in php
I am trying to find a php equivalent function of java getBytes() Havent found anything yet but found some answers, nothing co开发者_运维百科ncrete. http://www.phpbuilder.com/board/archive/index.php/t-10247795.html
Thanks
You mean the string function right?
$string = "texttexttext";
$bytes = array();
for($i = 0; $i < strlen($string); $i++){
$bytes[] = ord($string[$i]);
}
print_r($bytes);
--Output--
Array
(
[0] => 116
[1] => 101
[2] => 120
[3] => 116
[4] => 116
[5] => 101
[6] => 120
[7] => 116
[8] => 116
[9] => 101
[10] => 120
[11] => 116
)
精彩评论