Issue
the directory structure is like this
modules/
/module1
/messages/
/en
/admin.php
/profile.php
/ru/
/admin.php
/profile.php
/module2/
/messages/
/en
/account.php
/stats.php
/ru
/account.php
/stats.php
each of thos php files has a huge array inside where by the array contains a key value pair of the text strings like e.g
return array(
'hello' => 'aloha'
);
so how to get the arrays in each files ?
Solution
you may implement new method to achieve this using glob()
php function
$language = 'en';
foreach (glob('modules/*/messages/' . $language . '/*') as $file) {
echo "$file\n";
}
Output :
modules/module1/messages/en/admin.php
modules/module1/messages/en/profile.php
modules/module2/messages/en/admin.php
modules/module2/messages/en/profile.php
to return arrays from inside those files :
$language = 'en';
$arrays = [];
foreach (glob('modules/*/messages/' . $language . '/*') as $file) {
$arrays[] = require_once "$file";
}
print_r($arrays);
Answered By - hassan
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.