• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 534
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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