Hash tables for PHP (#39)

This commit is contained in:
Vendin
2017-11-13 19:12:01 +03:00
committed by Aditya Bhargava
parent b88af07fd0
commit 1a81d3e6b2
2 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
<?php
$voted = [];
function check_voter($name)
{
global $voted;
if (isset($voted[$name])) {
print "kick them out!\n";
} else {
$voted[$name] = true;
print "let them vote!\n";
}
}
check_voter("tom"); // let them vote!
check_voter("mike"); // let them vote!
check_voter("mike"); // kick them out!