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