Created
June 6, 2021 07:59
-
-
Save bijancot/2568997cba9e8fa4bda9a5b6633a9b5b to your computer and use it in GitHub Desktop.
loop with some condition
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
| <!DOCTYPE html> | |
| <html> | |
| <body> | |
| <?php | |
| //x inputan user | |
| $x = array("7","5"); | |
| //y data dari database | |
| $y = array("2","4","3"); | |
| $skor=0; | |
| for($a=0;$a<sizeof($x);$a++) | |
| { | |
| for($b=0;$b<sizeof($y);$b++){ | |
| if($x[$a]==$y[$b]){ | |
| if($x[$a]==$x[$a-1]){ | |
| continue; | |
| } | |
| else{ | |
| $skor+=1; | |
| } | |
| } | |
| else{ | |
| //do nothing | |
| } | |
| } | |
| } | |
| echo $skor."/".sizeof($y)."</br>"; | |
| $hasil = ($skor/sizeof($y))*100; | |
| echo "Hasil Akhir : ".round($hasil,2)."%"; | |
| ?> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment