public static function toIsbn10($ean, $onError = null)
    {
        // Sanitize
        $ean = preg_replace('/[^0-9]/', '', $ean);

        // Validate
        if (!preg_match('/^978(\d{9})\d?$/', $ean, $found)) {
            return $onError;
        }

        // Convert
        $isbn = $found[1];
        $isbn = static::withCheckDigitForIsbn10($isbn);

        return $isbn ?: $onError;
    }
public static function toIsbn10($ean, $onError = null)
    {
        // Sanitize
        $ean = preg_replace('/[^0-9]/', '', $ean);

        // Validate
        if (!preg_match('/^978(\d{9})\d?$/', $ean, $found)) {
            return $onError;
        }

        // Convert
        $isbn = $found[1];
        $isbn = static::withCheckDigitForIsbn10($isbn);

        return $isbn ?: $onError;
    }
public static function toIsbn10 ( $ ean , $ onError = null ) { // Sanitize $ ean = preg_replace ( '/[^0-9]/' , '' , $ ean ) ; // Validate if ( ! preg_match ( '/^978(\d{9})\d?$/' , $ ean , $ found ) ) { return $ onError ; } // Convert $ isbn = $ found [ 1 ] ; $ isbn = static :: withCheckDigitForIsbn10 ( $ isbn ) ; return $ isbn ? : $ onError ; }
Convert isbn13 to isbn10.

@param string $ean     isbn13
@param mixed  $onError [optional] string to return if value is not specified type.

@return mixed
Convert isbn13 to isbn10 .