<?php

function pandigital($number) {
    $array = count_chars($number,1);
    ksort($array);
    if($array == array(49=>1,50=>1,51=>1,52=>1,53=>1,54=>1,55=>1,56=>1,57=>1)) { return true;} else { return false; }
}

$products = [];
for($a = 1; $a <= 2500; $a++) {
    for($b = 1; $b <= 2500; $b++) {
        $p = $a*$b;
        $str = (string)$a.$b.$p;
        if(strlen($str) == 9 && pandigital($str))
        {
            $products[] = $p; 
            echo "Found $a*$b=$p\n";
        }
    }
}

$products = array_unique($products);
echo array_sum($products).PHP_EOL;