function _phrase_captcha_word_question_word_index in CAPTCHA Pack 5
Same name and namespace in other branches
- 8 text_captcha/modules/phrase_captcha/phrase_captcha.module \_phrase_captcha_word_question_word_index()
- 6 text_captcha/phrase_captcha/phrase_captcha.inc \_phrase_captcha_word_question_word_index()
- 7 text_captcha/phrase_captcha/phrase_captcha.module \_phrase_captcha_word_question_word_index()
File
- text_captcha/
phrase_captcha/ phrase_captcha.module, line 193
Code
function _phrase_captcha_word_question_word_index($words) {
$key = array_rand($words, 1);
$answer = $words[$key];
if (mt_rand(0, 1)) {
$description = t('What is the @nth word in the CAPTCHA phrase above?', array(
'@nth' => _phrase_captcha_ordinal($key + 1),
));
}
else {
$n = count($words) - $key;
if ($n == 1) {
$description = t('What is the last word in the CAPTCHA phrase above?');
}
else {
$description = t('What is the @nth last word in the CAPTCHA phrase above?', array(
'@nth' => _phrase_captcha_ordinal($n),
));
}
}
return array(
$words,
$description,
$answer,
);
}