foreach on a 3d array
| From: | Dotan Cohen | Date: | Tue, 24 Oct 2006 20:27:24 +0000 |
| Subject: | foreach on a 3d array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-243590@lists.php.net to get a copy of this message | ||
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/