• 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

Can't call javascript alert alertify library from PHP

Why the name of trucks are same in 2nd and 3rd record of company data retrieval?

Add a text next to stock quantity if it is less than 10 in Woocommerce single product

jwt decode throws Invalid argument supplied for foreach() on php-jwt and codeignitor 4

How to read laravel_session cookies saved in cookie memory of browser in client side?

PHP Get value from JSON [duplicate]

Webscraping Symfony/Panther: Can't get HTML

Yii2: How to download backup files using spanjeta/yii2-backup?

Symfony Error: "An exception has been thrown during the rendering of a template"

PHP SoapClient: set a namespace without prefix

javascript html popup window

PHP-Sort array based on another array?

Destroy session upon refresh

How to install LDAP in Docker php-fpm alpine

Facebook PHP SDK - will not logout properly

About Contact Privacy policy Terms and conditions