Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
@gueryacine
gueryacine / validateImei.php
Last active March 29, 2016 15:08 — forked from kasperhartwich/validateImei.php
PHP function to validate IMEI numbers.
function validateImei($imei, $use_checksum = true) {
if (is_string($imei)) {
if (preg_match('/^[0-9]{15}$/', $imei)) {
if (!$use_checksum) return "Code IMEI Invalide (manque de chiffre ou utilisation de caractere alphabitique";
for ($i = 0, $sum = 0; $i < 14; $i++) {
$tmp = $imei[$i] * (($i%2) + 1 );
$sum += ($tmp%10) + intval($tmp/10);
}
if(((10 - ($sum%10)) %10) == $imei[14])
return "Code Valide";