Welcome Guest, Not a member yet? Register   Sign In
Get array lang variables
#6

(This post was last modified: 01-20-2020, 02:09 PM by JNapolitanoIT.)

You could try using nested arrays inside of your language files, as seen here.  You can then access the values like below.

Using the same example, let's assume you've got a file living inside of app/Language/en/Test.php:

Code:
return [
    'lang_array_1' => [
        'key_one' => 'Value One',
        'key_two' => 'Value Two
    ],
    'lang_array_2' => [
        'key_one' => 'Value One',
        'key_two' => 'Value Two
    ]

];

You can now access it like so:

Code:
return lang('Test.lang_array_1');
return lang('Test.lang_array_2')

To get the values inside of the lang_array's. This may seem a little tedious but it does what you'd like it to.

I have to agree on not using any require's and require_once's in your code and using the systems API instead as it's more consistent and full proof should anything change internally within the framework itself.

I hope that this helps Smile
Reply


Messages In This Thread
Get array lang variables - by mintwint - 01-17-2020, 01:51 PM
RE: Get array lang variables - by JNapolitanoIT - 01-17-2020, 05:53 PM
RE: Get array lang variables - by mintwint - 01-18-2020, 07:57 AM
RE: Get array lang variables - by littlej - 01-19-2020, 04:17 PM
RE: Get array lang variables - by mintwint - 01-20-2020, 01:19 PM
RE: Get array lang variables - by JNapolitanoIT - 01-20-2020, 01:58 PM
RE: Get array lang variables - by mintwint - 01-21-2020, 08:09 AM
RE: Get array lang variables - by JNapolitanoIT - 01-21-2020, 10:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB