You are here: Re: Getting deep array value without knowing keys? « PHP Programming Language « IT news, forums, messages
Re: Getting deep array value without knowing keys?

Posted by Schraalhans Keukenmeester on 05/25/07 07:01

At Thu, 24 May 2007 14:20:36 -0700, rbutlerjr let his monkeys type:

> 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...

list ($lng,$opt,$str) = explode ($request, $delimiter);
$output = (!empty ($lang[$lng][$opt][$str])) ? $lang[$lng][$opt][$str] :
'Invalid Request';

Something like that?
Sh.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация