Project Euler Solutions by Ross Marks

<?php
/*****************************
 * ProjectEuler - Problem 32
 * By Ross Marks
 *****************************
 * We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital.
 * 
 * The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital.
 * 
 * Find the sum of all products whose multiplicand/multiplier/product identity can be written as a 1 through 9 pandigital.
 * 
 * HINT: Some products can be obtained in more than one way so be sure to only include it once in your sum.
 ****************************/

$awns 0;
$products = array();

//$pannie = 15234;
//echo (isPandigital($pannie)? "true": "false");

for($a 1$a <= 2000$a++){
    for(
$b 1$b <= 2000$b++){
        
$ext $a $b;
        if(
isPandigital($a.$b.$ext) && strlen($a.$b.$ext) == 9){
            
$products[] = $ext;
            
//echo $a." X ".$b." = ".$ext."\n";
        
}
    }
}

$unique_products array_unique($products);
foreach(
$unique_products as $toadd)
    
$awns bcadd($awns$toadd);

echo 
"Answer: $awns";

function 
isPandigital($number){
    
$nos strlen($number);
    
$count 0;
    for(
$i 1$i <= $nos$i++)
        if (
strpos("$number""$i") !== false)
            
$count++;
    
    if(
$count == $nos)
        return 
true;
    return 
false;
}

?>