Your Location is: Home > Php

Include language array in Codeigniter 4

From: Germany View: 2938 Henry8 


I receive the "language segment" from the url (I use CodeIgniter 4)


I would like to load the relative translations array in the controller ready for the view... so I tried:

My controller:

$data['tran'] = array(require_once(APPPATH."/Language/en/file_lang.php"));


$lang = array();

$lang['t1'] = "Description";
$lang['t2'] = "list";
$lang['t3'] = "Contact";
$lang['t4'] = "Write";
$lang['t5'] = "Views";
$lang['t6'] = "Cities";

In my view

echo ($tran['t1']);  

I receive this error: Undefined index: t1

Does not work... why?

Best answer