Hi,
I'm a newbie at PHP and I have a very mysterious problem.
I have a class varaible $pos_table that is filled with data by function getRatesTable() in the constructor.
Later, in a member class when I try to retrieve data...it keeps returning the complete array no matter if i try to retrieve:
$this->$pos_table['SE'][0] or
$this->$pos_table['NO'] or
$this->$pos_table['FI'][3].
I cannot understand why. Please see stripped code below:
//the method called by the constructor
function getRatesTable()
{
$sek_lmt = array(10000,119,30000,249);
$dkk_lmt = array(8000,119,25000,199);
$eur_lmt = array(1000,14,3000,24);
$nok_lmt = array(8000,99,20000,149);
$my_curr = new currencies;
$sek = $my_curr->get_value('SEK');
$dkk = $my_curr->get_value('DKK');
$eur = $my_curr->get_value('EUR');
$nok = $my_curr->get_value('NOK');
$tmp = array(
"SE" => array($sek_lmt[0], ($sek_lmt[1] * 0.8 / $sek), $sek_lmt[2], ($sek_lmt[3] * 0.8 / $sek), 10000000, 0),
"DK" => array($dkk_lmt[0], ($dkk_lmt[1] * 0.8 / $dkk), $dkk_lmt[2], ($dkk_lmt[3] * 0.8 / $dkk), 10000000, 0),
"FI" => array($eur_lmt[0], ($eur_lmt[1] * 0.8 / $eur), $eur_lmt[2], ($eur_lmt[3] * 0.8 / $eur), 10000000, 0),
"NO" => array($nok_lmt[0], ($nok_lmt[1] * 1.0 / $nok), $nok_lmt[2], ($nok_lmt[3] * 1.0 / $nok), 10000000, 0)
);
return $tmp;
}
class zones {
var $pos_table;
// class constructor
function zones() {
$this->$pos_table = getRatesTable();
}
function my_test_func()
{
print_r($this->$pos_table);
print_r($this->$pos_table['SE]);
echo $this->$pos_table['DK'][2];
}
}
// run code:
$my_zones = new zones;
$my_zones->my_test_func();
Every call for print_r prints the full array.
The echo states "Array".
What in the world is wrong???? I cannot see it :/
Any help is greatly appreciated
Thanks/
Pontus