Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String to byte/binary arrays in PHP

Tags:

arrays

php

How do I convert a string to a binary array in PHP?

like image 710
Jeff Winkworth Avatar asked May 08 '09 15:05

Jeff Winkworth


2 Answers

I think you are asking for the equivalent to the Perl pack/unpack functions. If that is the case, I suggest you look at the PHP pack/unpack functions:

  • Unpack
  • Pack
like image 86
earino Avatar answered Oct 08 '22 21:10

earino


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

like image 28
McAden Avatar answered Oct 08 '22 21:10

McAden