|
Posted by Rik on 08/11/06 22:43
Bint wrote:
> Hi,
> I have an array of numbers, and I need to turn it into a single
> binary string. How do I do that?
> Thanks
> B
Concating the items from decimal to binary?
I'm not really sure how you want to do this, but something like this:
$array = array(7,12,10,2,3);
function concat_dec2bin($v,$w){
$v .= decbin($w);
return $v;
}
$string = array_reduce($array,'concat_dec2bin');
Which will result in 111110010101011 (111 = 7, 1100 = 12,1010 = 10,10 = 2,
11 = 3);
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|