3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function ean_checksum($eancode) { $result = false; if(strlen($eancode) == 13) { $check_code = substr($eancode, 12, 1); $eancode = substr($eancode, 0, 12); $oddsum=0; $evensum=0; $total=0; $eanvalue=$eancode; $finalean = strrev(substr($eanvalue,0,12)); for($i=0;$i<strlen($finalean);$i++) { if(($i % 2) == 0) { $oddsum += intval($finalean[$i]); } else { $evensum += intval($finalean[$i]); } } $total = ($oddsum * 3) + $evensum; $check = intval(10 - ceil($total % 10.0)) %10; if($check == $check_code) { $result = true; } } return $result; } $t = array('3603912289411','0709710008000','6039122554470','0709711001000','0716770159659','7167700499971','0370079230001','0744361007200','0005280050201','0005280010201'); foreach($t as $v) {var_dump(ean_checksum($v));}
based on 7F3Gv
Output for 4.3.0 - 7.1.0
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false)