2
这里的想法是有一系列的应用技巧/语言/英文/ tips_lang.phpCodeIgniter PHP - 如何随机选择语言类消息?
$lang['tip1'] = 'Water your plants';
$lang['tip2'] = 'Aerate your soil';
$lang['tip3'] = 'Use ventilation';
$lang['tip4'] = 'Fertilizers are good';
etc...
在我的控制,我想有这样的事情伪代码
$input = $this->lang->line('tip_array');
$tip = array_rand($input, 1);
任何人都知道这是可能的吗?
感谢您的帮助!
更新控制器
//Random Tip
$array = explode('|', $this->lang->line('tips'));
$tips = array_rand($array, 1);
$this->template->write('tips', $tips);
thanks @alix - 不知道如何处理最后一行代码中的'$ language' - 它会生成一个错误 – pepe 2011-05-01 03:54:28
@torr:对不起,这是一个错字 - 修正了它! – 2011-05-01 03:55:34
;) - 确定 - 这现在可以工作,但以一种有趣的方式 - 我得到随机线回显我的看法,但他们也是从另一个lang文件在同一文件夹中。我正在使用自动加载的提示lang文件和这个其他的lang文件。这可能是问题吗? – pepe 2011-05-01 03:58:51