1

Topic: Pulling an array from file

Yet another of my wayward questions. smile Is there a simple way to, (for example with the langfiles), create a master array, along the lines of:

$lang = array(

'common'                =>      $lang_dir.'common.php',
'delete'                =>      $lang_dir.'delete.php',
'userlist'              =>      $lang_dir.'userlist.php',

);

        foreach ($lang as $key => $langfile)
        {
                [Create the above array from the contents of this $langfile];
        }

so that they could be referenced as:

$lang['common']['index']

rather than:

$lang_common['index']

?

Would it be a case of removing the array command from those files and reading them in to achieve it, or is there another, more straight forward method? Also, would the above actually work okay? big_smile


Cheers,

Matt

Re: Pulling an array from file

You could change all the files so they do something like $lang['common'] = rather than $lang_common =, that would be the easiest way.

3

Re: Pulling an array from file

I feel such a muppet now you've pointed it out. I've been head scratching for a couple of hours over this, and the penny just never dropped that it could be that simple. big_smile

Thanks ever so much Smartys. smile

4

Re: Pulling an array from file

Just wanted to say thanks for the pointer on how to do this Smartys. smile It's made life so much easier now with the new method.

Re: Pulling an array from file

Having all of them in the same array actually makes more sense as compared to what we have now. Hmm.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

6

Re: Pulling an array from file

It definitely makes life easier. smile Functions were the main reason for changing things here. I've been running full E_ALL on errors for the last week or two, (just tracking down any slight typo's or such I may have missed), and that method has definitely saved a lot of function checking for required lang files, especially with the redirect function.