<?php $sum = []; for($n = 10; $n <= 99; $n++) { for($d=$n+1;$d <= 99; $d++) { foreach([1,2,3,4,5,6,7,8,9] as $digit) { $ns = (int)str_replace($digit, '', $n); $ds = (int)str_replace($digit, '', $d); if($n != $ns && $d != $ds && $d != 0 && $ds != 0) { if($n/$d == $ns/$ds) { echo "$n/$d = $ns/$ds\n"; $sum[] = $ns/$ds; } } } } } echo array_product($sum).PHP_EOL;