• 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

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

PHP: How to solve ob_start() in combination imagepng() issue?

Trying to iterate over a mongodb cursor twice - failing

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

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

Select option from dropdown menu with PHP and mySql

Laravel no logout option from menu after successfull login

Invalid value in field "itemtype" in Google Search Console

GRPC installed successfully on ubuntu but php is looking for it in another folder

How to loop sql table data inside a html table

PHP - Check if string contains words longer than 4 characters, then include "+ *", and for those shorter than 4 characters include only "*"

PHP only Hit Counter?

How to run a shell as root from php (apache)

Doctrine 2 mapping referencing unique key

Cannot pass null argument when using type hinting

About Contact Privacy policy Terms and conditions