我有一个.txt格式的字典单词列表。如何使用 captcha_helper 而不是随机字符?我已经扩展了captcha_helper文件,但是在集成我的wordlist.txt
文件时遇到了问题。
在做了一些戳之后,我找到了一个解决方案:
// This is the modified version in captcha_helper.php
if($word == ''){
$wordsfile = '../words.php';
$fp = fopen($wordsfile, 'r');
$length = strlen(fgets($fp));
$line = rand(1, (filesize($wordsfile)/$length)-2);
if(fseek($fp, $length*$line) == -1) return FALSE;
$word = trim(fgets($fp));
fclose($fp);
}
但我注意到有时最后一封信会被切断。有没有办法确保第一个和最后一个字母永远不会放在边界框之外?
答案 0 :(得分:0)
在这种情况下,您可以使用一个函数将您的单词随机传递给脚本以显示..
我认为这是更好的选择。
而不是工作机智