Robson » Code » PHP » Pandigital

 
<?
   // pandigital checker v1.0
 
   // to qualify as unique pandigital, the number must contain
   // one of each digit up to the length of the number
   // example valid with zero: 40132 or 9826351047
   // example valid without zero: 1342 or 982736451
   function is_pandigital($number, $zero=true)
   {
       $number = str_split($number);
       sort($number);
       return implode($number) === substr('0123456789', !$zero, count($number));
   }
?>    
 
© 2004-17 robson | cc unless stated