you need to declare your $monthname var as global, now you can use it!

function show_lang_date($timestamp, $country)
{
  GLOBAL $monthname;

  $date = getdate($timestamp);
  echo "mday = ". $date['mday'] . " ";
  echo "country = $country ";
  $mon = $date["mon"];
  echo "mon = ". $mon . " ";
  echo $monthname[$country][$mon];
  echo "\n";
}



"Willem Van Der Scheun" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
Hi,

I've written the piece of code below and I do not get any output out of the
2 dimensional array. I do not see what's wrong. Must be something obvious I
guess.

<?php

$monthname["NL"][1] = "Januari";
$monthname["NL"][2] = "Februari";
$monthname["NL"][3] = "Maart";
$monthname["NL"][4] = "April";
$monthname["NL"][5] = "Mei";
$monthname["NL"][6] = "Juni";
$monthname["NL"][7] = "Juli";
$monthname["NL"][8] = "Augustus";
$monthname["NL"][9] = "September";
$monthname["NL"][10] = "Oktober";
$monthname["NL"][11] = "November";
$monthname["NL"][12] = "December";

$monthname["BR"][1] = "Janeiro";
$monthname["BR"][2] = "Fevreiro";
$monthname["BR"][3] = "Março";
$monthname["BR"][4] = "Abril";
$monthname["BR"][5] = "Maio";
$monthname["BR"][6] = "Junho";
$monthname["BR"][7] = "Julho";
$monthname["BR"][8] = "Augosto";
$monthname["BR"][9] = "Setembro";
$monthname["BR"][10] = "Outobro";
$monthname["BR"][11] = "Novembro";
$monthname["BR"][12] = "Decembro";

$monthname["EN"][1] = "January";
$monthname["EN"][2] = "February";
$monthname["EN"][3] = "March";
$monthname["EN"][4] = "April";
$monthname["EN"][5] = "May";
$monthname["EN"][6] = "June";
$monthname["EN"][7] = "July";
$monthname["EN"][8] = "August";
$monthname["EN"][9] = "September";
$monthname["EN"][10] = "October";
$monthname["EN"][11] = "November";
$monthname["EN"][12] = "December";

function show_lang_date($timestamp, $country)
{
  $date = getdate($timestamp);
  echo "mday = ". $date['mday'] . " ";
  echo "country = $country ";
  $mon = $date["mon"];
  echo "mon = ". $mon . " ";
  echo $monthname[$country][$mon];
  echo "\n";
}

$timestamp = time();
show_lang_date($timestamp, "NL");
show_lang_date($timestamp, "BR");
show_lang_date($timestamp, "EN");

?>

When I run this I get the following output

Content-type: text/html
X-Powered-By: PHP/4.3.3

mday = 28 country = NL mon = 3
mday = 28 country = BR mon = 3
mday = 28 country = EN mon = 3

so no monthname!

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

Reply via email to