How do I convert a string to a binary array in php?
A:
There is no such thing as a binary array in php. All functions requiring byte streams operate on strings. What is it exactly that you want to do?
soulmerge
2009-05-08 15:53:01
+1
A:
If you're trying to access a specific part of a string you can treat it like an array as-is.
$foo = 'bar';
echo $foo[0];
output: b
McAden
2009-05-08 17:02:49
For this kind of string access, I believe curly brace notation is preferable (otherwise you risk confusing the hell out of anyone else maintaining your code). For example: $foo{0}
EvanK
2009-05-08 18:35:11
Unless I'm mistaken, Curly brace notation for this is deprecated in PHP 6
McAden
2009-05-08 21:42:32
Ah, here it is: http://us.php.net/language.types.stringThe "Note" under the heading - "String access and modification by character"
McAden
2009-05-08 21:46:00
+1
A:
I think what you are asking for is the equivalent to the perl pack/unpack functions. If that is the case, I suggest you look at the PHP pack/unpack functions:
earino
2009-05-08 17:06:08