SlightPHP\SimpleCaptcha::GetDictionaryCaptchaText PHP Method

GetDictionaryCaptchaText() public method

Random dictionary word generation
public GetDictionaryCaptchaText ( boolean $extended = false ) : string
$extended boolean Add extended "fake" words
return string Word
    function GetDictionaryCaptchaText($extended = false)
    {
        if (empty($this->wordsFile)) {
            return false;
        }
        $fp = fopen($this->wordsFile, "r");
        $length = strlen(fgets($fp));
        if (!$length) {
            return false;
        }
        $line = rand(0, filesize($this->wordsFile) / $length - 1);
        if (fseek($fp, $length * $line) == -1) {
            return false;
        }
        $text = trim(fgets($fp));
        fclose($fp);
        /** Change ramdom volcals */
        if ($extended) {
            $text = str_split($text, 1);
            $vocals = array('a', 'e', 'i', 'o', 'u');
            foreach ($text as $i => $char) {
                if (mt_rand(0, 1) && in_array($char, $vocals)) {
                    $text[$i] = $vocals[mt_rand(0, 4)];
                }
            }
            $text = implode('', $text);
        }
        return $text;
    }