function _phrase_captcha_word_question_double_occurence in CAPTCHA Pack 5
Same name and namespace in other branches
- 8 text_captcha/modules/phrase_captcha/phrase_captcha.module \_phrase_captcha_word_question_double_occurence()
- 6 text_captcha/phrase_captcha/phrase_captcha.inc \_phrase_captcha_word_question_double_occurence()
- 7 text_captcha/phrase_captcha/phrase_captcha.module \_phrase_captcha_word_question_double_occurence()
File
- text_captcha/
phrase_captcha/ phrase_captcha.module, line 235
Code
function _phrase_captcha_word_question_double_occurence($words) {
// assure single occurence of each word
$words = array_unique($words);
// pick a word
$key = array_rand($words, 1);
$answer = $words[$key];
// replace another word with it
while (($pos = array_rand($words, 1)) == $key) {
}
array_splice($words, $pos, 1, $answer);
$description = t('Which word occurs two times in the CAPTCHA phrase above?');
return array(
$words,
$description,
$answer,
);
}