My code is like this :
<?php
function binary_to_decimal($a) {
$bin_array = str_split($a);
$y=sizeof($bin_array)-1;
for ($x=0; $x<sizeof($bin_array)-1; $x++) {
if ($bin_array[$x] == 1) {
$bin_array[$x] = bcpow(2, $y);
}
$y--;
}
for ($z=0; $z<sizeof($bin_array); $z++) {
$result = bcadd($result, $bin_array[$z]);
}
echo $result;
}
binary_to_decimal('11111');
?>
It still using PHP native functions. For example : bcpow, sizeof, bcadd.
Whether it can convert binary to decimal without using PHP native functions?
Thank you
bindec