• 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

Sort a multidimensional array by integer inside of a string value which is two levels down

Custom API and cunsuming in php?

How to show a popup modal in codeIgniter?

PHP DOTENV unable to load env vars

In PHP, which is faster: preg_split or explode?

Limit WooCommerce products in cart only from one custom taxonomy

PHP | "The requested PHP extension bcmath is missing from your system."

How do I get friend list from Friends table with counts of friends of my friends

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

How to trim a video by 4 fragments to 4 seconds using the PHP-FFMpeg?

Component install error: JInstaller: :Install: File does not exist

How to run or debug php on Visual Studio Code (VSCode)

Cannot pass null argument when using type hinting

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

About Contact Privacy policy Terms and conditions