Ask about general coding issues or problems here.
Moderators: macek, egami, gesf
I am trying to construct an associative array by using a function to populate some of the values as follows.
$month = array(1 => translate('January'), 2 => translate('February'),.......................12 => translate('December'))
translate() is a function I am using to translate English words and names to French. I have used it everywhere else and it has worked fine. My question is, is it not possible to call a function in this way to populate part of an associative array?
- New php-forum User
- Posts: 1
- Joined: Tue Mar 25, 2014 8:28 am
Your challenge is coming from the scope of the variable containing the array. If you're declaring it outside of the function, make sure you use global $variableName; in the function to specify that you're going to be referencing th global variable rather than one in local scope. if the variable is defined locally to the function (inside the function) then you'd have to return it to the calling context in order to make the results available
- php-forum Fan User
- Posts: 838
- Joined: Mon Oct 01, 2012 12:32 pm
Return to PHP coding => General
Who is online
Users browsing this forum: Google [Bot] and 5 guests