PHP: bindec function
Description
The bindec() function is used to convert a binary number to a decimal number.
Version:
(PHP 4 and above)
Syntax:
bindec(string_num)
Parameter:
Name | Description | Required / Optional |
Type |
---|---|---|---|
string_num | The binary string to convert. | Required | String |
Return value:
The decimal value of string_num
Value Type: Integer / Float.
Pictorial Presentation:
Example:
<?php
$val1= '110011';
$val2='110';
$val3='11100111';
$zdec1=bindec($val1);
$zdec2=bindec($val2);
$zdec3=bindec($val3);
echo "Decimal value of $val1 is $zdec1<br />";
echo "Decimal value of $val2 is $zdec2<br />";
echo "Decimal value of $val3 is $zdec3<br />";
?>
Output:
Decimal value of 110011 is 51 Decimal value of 110 is 6 Decimal value of 11100111 is 231
View the example in the browser
See also
Previous: base_convert
Next: ceil
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/php/function-reference/bindec.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics