Created
February 24, 2016 12:08
-
-
Save yeknava/765a5830e08da285becf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ncode = '0011111111'; | |
| $ncodeArray = str_split($ncode); | |
| $sum = 0; | |
| for($i=0; $i<10; $i++) { | |
| $sum = intval($ncodeArray[$i])*($i+1); | |
| } | |
| $mod11 = $sum%11; | |
| if($mod11 < 2) { | |
| if(intval($mod11) === intval($ncodeArray[9])) { | |
| return true; | |
| } else { | |
| return false; | |
| } | |
| } else { | |
| if(intval($ncodeArray[9]) === (11-$mod11)) { | |
| return true; | |
| } else { | |
| return false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment