• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 508
  • Last Modified:

PHP - decimal number to binary - array needed

I want to take a decimal number such at 53 which equals  110101.

I want to be able populate an array such as $data(0)=1,  $data(1)=0,  $data(2)=1, $data(3)=0, $data(4) =1,  etc


I did read up on the function decbin but kinda confused on putting the individual its into an array.
0
keith1001
Asked:
keith1001
1 Solution
 
GaryCommented:
<?php
$number=53;
$binary = decbin($number);
$binArray=str_split($binary);
var_dump($binArray);

Open in new window

0
 
keith1001Author Commented:
Thank you, my brain was not functioning to good this morning.  Perfect!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now