Skip to content

Instantly share code, notes, and snippets.

@bijancot
Created June 6, 2021 07:59
Show Gist options
  • Select an option

  • Save bijancot/2568997cba9e8fa4bda9a5b6633a9b5b to your computer and use it in GitHub Desktop.

Select an option

Save bijancot/2568997cba9e8fa4bda9a5b6633a9b5b to your computer and use it in GitHub Desktop.
loop with some condition
<!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