You are here: Re: how do you make a string of binary numbers from an array « PHP Programming Language « IT news, forums, messages
Re: how do you make a string of binary numbers from an array

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация