foreach on a 3d array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have an array that lloks like this:

$languages = array(
   "af"  => array("Afrikaans", "Afrikaans", "South Africa"),
   "sq"  => array("Albanian", "Shqipe", "Albania")        );


Now, if the user's $_HTTP_ACCEPT_LANGUAGE contains, for example, "af",
I want to print the third value of the subarray for that value. This
code would not work, naturally, as I'm doing it wrong. I have been
unable to google a working example. Could someone please show me what
I'm doing wrong:

foreach ($languages as $language){
   if (  strstr( $_HTTP_ACCEPT_LANGUAGE, $language)  ) {
       print"<center>You are from ".$language[2]."!</center>";
   }
}

Thank in advance for any assistance.

Dotan Cohen

http://lyricslist.com/
http://what-is-what.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux