doudou6719 2015-11-04 15:48
浏览 50
已采纳

laravel 4:从sql表生成语言文件数组

I would like to use a content table where I have all the translation values. In laravel 4, we have a language file with the following script :

return array(
    "password" => "Passwords must be at least six characters and match the confirmation.",

    "user" => "We can't find a user with that e-mail address.",

    "token" => "This password reset token is invalid.",

    "sent" => "Password reminder sent!",

);

I create this array by a foreach with the following script :

$array = DB::table('Content_BO_Reminder')->get();
$returnarray = array();
foreach ($array as $value) {
    $returnarray[] =  '
    \''.$value->key.'\' => \''.$value->value_en.'\',
    ';
}
return $returnarray;

But the result when i try to call the following function {{trans('reminder.password')}} is reminder.password.

Any one has an idea? Thanks in advance

  • 写回答

1条回答 默认 最新

  • dongshun5963 2015-11-04 16:03
    关注

    Try this:

    foreach ($array as $value) {
        $returnarray[$value->key] = $value->value_en;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大