I'm trying to make it translate binary

 
<?php
//get the variable
$code = $_POST['bicode'];
//make sure they are numbers
$check = ereg ("^[01]+", $code);

//With an if statment
If ($check){
	//Start the code to interpret it
	$chars = count($code);
		//start the loop
		for ($a = 0; $a < $chars; $a++) {

	//Make another variable, an excuse for a, just for caution
	$b = $a;
	//We need to start the answer somewhere
	$answer = 1;
		//Make another for loop so you can times it by powers (I need help here)
		for ($z=0; $z < $a; z++){

			//Take the number and multiply by itself
			$answer = $answer * $code[$b];


	}

//Tell them what it is
echo "$answer";

}

//If it's not proper, tell them so	
else{
echo "This is not proper binary code";
}


?>
    <?php
    //get the variable
    $code = '1000110011001';
    //make sure they are numbers
    $check = ereg ("^[01]+", $code);
    
    //With an if statment
    if ($check!=false) {
      //Start the code to interpret it
      $chars = count($code);
      //start the loop
      for ($a = 0; $a < $chars; $a++) {
        //Make another variable, an excuse for a, just for caution
        $b = $a;
        //We need to start the answer somewhere
        $answer = 1;
        //Make another for loop so you can times it by powers (I need help here)
        for ($z=0; $z < $a; $z++){
          //Take the number and multiply by itself
          $answer .= $answer * $code[$b];
        }
      }
     //Tell them what it is
      echo "$answer";
    
    } else {
      echo "This is not proper binary code";
    }
    
    
    ?>
    

    That just fixes a few errors i found. Not sure if thats the help you wanted

      Nope, it doesn't show anything, I have no Idea what's wrong.

        If this is working code intended for critique, I'd suggest that [man]bindec[/man] would do most of the job.

          worships Oh great master of simplifying big fuctions!

            Write a Reply...