5

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 concrete. http://www.phpbuilder.com/board/archive/index.php/t-10247795.html

Thanks

0

1 Answer 1

5

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
)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.