Solved

PHP - decimal number to binary - array needed

Posted on 2014-03-22
2
457 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
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

825 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