function conv_isbn ($isbn
{
$isbn = "978" . $isbn; //add ‘978’ prefix
$isbn = str_split$isbn); //split into 13-element array
$m=3; //initialize variables
$sum=0;
for$i=0; $i<12; $i++)
{
($m==1) ? $m=3 : $m=1; //alternate $m between 1 & 3
$sum+=($isbn$i]*$m); //sum products
}
$isbn[12]=10-($sum%10); //Write new check digit (10 - $sum%10)
$isbn = implode$isbn);
return $isbn
}