• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How to load Codeigniter 4 lang file into an array variable

phparrayslocalizationlangcodeigniter-4


PHP Snippet 1:

return [
    'list' => [
        'Apples',
        'Bananas',
        'Grapes',
        'Lemons',
        'Oranges',
        'Strawberries'
    ]
];


$foo = lang('Fruit.list');

PHP Snippet 2:

$language = include('./Language/english.php')

PHP Snippet 3:

<?php
$locale = service('request')->getLocale();
$path = "Language/{$locale}/Validation.php";
$lang =  require APPPATH.$path; ;
var_dump($lang);
?>

Related Snippets

PHP Startup: Unable to load dynamic library 'openssl' in Ubuntu

Laravel/ PHP: Order By Alphabetical with numbers in order [duplicate]

PHP DOTENV unable to load env vars

Display specific shipping method if woocommerce product has specific acf field value

How to average columns of data from multiple, flat arrays?

Transpose and flatten multiple rows of array data [duplicate]

storagelogs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

Laravel Nova Dependency Container what are the allowed resource properties other than id in dependsOn

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

How to delete old images from public folder on update using Laravel

Laravel/docker-compose/redis - Class 'Redis' not found

PHP password_verify

possible options to create pdf file using html elements to generate invoice in php and codeigniter

How to get the total hour from starting time to end time in php

Create a zip file and download it

About Contact Privacy policy Terms and conditions