1. Home
  2. Computing & Technology
  3. PHP / MySQL

Bindec () PHP Function

By Angela Bradley, About.com

Definition: The Bindec () PHP function is used to convert a binary string into a decimal. In Bindec (x) the input x would be the binary string. If you aren't sure if a string is a binary number you can check it using the Isbinary () function.
Examples:
<?php
echo(bindec(10) . "<br />");
echo(bindec(1001010) . "<br />");
echo(bindec(111) . "<br />");
echo(-bindec(1011101) . "<br />");
?>

This will return:
2
74
7
-93

Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. PHP Functions
  5. Bindec PHP Function - Convert Binary to Decimal in PHP

©2009 About.com, a part of The New York Times Company.

All rights reserved.