$meja = array( 'dadu'=> array( 1, 2, 3, 4, 5, 6), 'koin'=> array('kepala', 'ekor') ); echo "mengocok dadu dan koin, dapat ekor n angka 1\n"; $total=0; do { $result_1 = $meja['dadu'][rand(0,5)]; $result_2 = $meja['koin'][rand(0,1)]; $total=$total+1; echo "$result_1\n"; echo "$result_2\n"; if ($result_1 == $meja['dadu'][0]) { if ($result_2 == $meja['koin'][1]) { $hasil = false; } } else { $hasil = true; echo "coba lagi\n";} } while ($hasil); echo "\ndapat!\n"; echo "$total kali pengulangan";
2 jempol