Solved

PHP - decimal number to binary - array needed

Posted on 2014-03-22
2
469 Views
Last Modified: 2014-03-22
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
Comment
Question by:keith1001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39947532
<?php
$number=53;
$binary = decbin($number);
$binArray=str_split($binary);
var_dump($binArray);

Open in new window

0
 

Author Closing Comment

by:keith1001
ID: 39947626
Thank you, my brain was not functioning to good this morning.  Perfect!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question