|
Posted by Jeff Johns on 05/25/07 15:02
On May 24, 5:20 pm, rbutle...@gmail.com wrote:
> Hi, I've racked my brain for the last few hours trying to figure
> this one out. I have an array of language strings such as :
>
> $lang = array();
> $lang['en']['prompt']['hello'] = 'hello';
> $lang['en']['prompt']['bye'] = 'goodbye';
> $lang['en']['number']['first'] = '1st';
>
> This is being used by an ajax routine, so I don't know which string
> will be requested at runtime. So, I've got $lang and a request
> ('en_prompt_hello'), and tried a few things such as:
>
> $request = explode ($request);
> $found_string = array_intersect_assoc ($lang, $request);
>
> to no avail. Short of having to do a complicated recursion searching
> at every available depth, is there an easy way to do this?
>
> Thanks...
Can I just ask your logic behind having such robust multidimensional
arrays? I am sure there is some reason but you could always just go:
$lang['en_prompt_hello'] = 'hello';
-THEN-
request('en_prompt_hello');
echo $lang[$request]; //hello
Unless you have a specific use for the way you set up your array why
do it. It's just hard to get a jist of why you constructed your arrays
in this manner from seeing a snippet of your code.
Navigation:
[Reply to this message]
|