我知道codeigniter-2默认情况下只能生成字母数字类型的验证码。我如何将其扩展为生成有意义的单词?
例如:
morning
overlooking
生成验证码的代码示例:
$vals = array(
'img_path' => './assets/captcha/',
'img_url' => 'http://url/assets/captcha/',
'img_width' => '130',
'font_path' => './assets/fonts/Moms_typewriter.ttf',
'img_height' => '33',
'expiration' => CAPTCHA_MAX_TIME_EXPIRATION
);
$cap = create_captcha($vals);
答案 0 :(得分:2)
只需使用array
并使用循环
<?php
$ab = array('Morning','Night','welcome','im here');
$word = '';
$n = 0;
while ($n < 1)
{
$word .= $ab[mt_rand(0,9)];
$n++;
}
$vals = array(
'word' => $word,
'img_path' => './assets/captcha/',
'img_url' => base_url().'assets/captcha/',
'img_width' => '130',
'font_path' => './assets/fonts/Moms_typewriter.ttf',
'img_height' => '33',
'expiration' => CAPTCHA_MAX_TIME_EXPIRATION
);