• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

PHP bindec function – Convert a number between arbitrary bases

by admin

Description

The bindec() function converts a binary number into a decimal number. It takes just one parameter, which is the number to convert. For example:

print decbin("10000"); // 16

Syntax:

bindec(string $binary_string): int|float

Up to a 32-bit number, or 2,147,483,647 decimal, can be converted.

Parameters

Parameter Description
binary_string The binary string to convert. Any invalid characters in binary_string are silently ignored

Return Values

Decimal integer form of a binary number

Examples

Example 1: Convert a binary number to decimal:

$number = "101010"; 
echo "Binary $number is ", bindec($number), "in decimal"; 

Filed Under: PHP

Some more articles you might also be interested in …

  1. PHP Function strncasecmp() – Binary safe case-insensitive string comparison of the first n characters
  2. PHP function chop() – Alias of rtrim()
  3. PHP asin function – Arc sine
  4. PHP function stripslashes() – Un-quotes a quoted string
  5. PHP ceil function – Round fractions up
  6. PHP function chunk_split() – Split a string into smaller chunks
  7. PHP cos function – Cosine
  8. htaccess Cheatsheet
  9. PHP function acos – Arc cosine
  10. PHP function chr() – Generate a single-byte string from a number

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright