0

I use this code:

$currency = new MyCurrency();
print_r($currency);

to load/print the following Object:

MyCurrency Object (
[currencyCode:protected] => EUR
[currencies:protected] => Array (
[USD] => Array ( [currency_id] => 1 [currency_name] => US Dollar [left_symbol] => $  [exchanged_value] => 1.12000000 )
[EUR] => Array ( [currency_id] => 2 [currency_name] => Euro [left_symbol] =>  €  [exchanged_value] => 1.00000000 )
[GBP] => Array ( [currency_id] => 3 [currency_name] => Pound Sterling [left_symbol] => £  [exchanged_value] => 0.89999998 )
))

I am trying to get the active currency [currencyCode:protected] =>EUR and values from the Array [currencies:protected] but fail no matter what.

Can i get the values to variables in the way that i am trying? (The following are definitely wrong but they are an example of what i am trying)

$active_currency = $currency->currencyCode;
$USD_icon = $currency->currencies[USD]->left_symbol;
$USD_value = $currency->currencies[USD]->exchanged_value;
1

1 Answer 1

0

I was able to access the class and use a public function in order to get the values that i needed the correct way.

$currency = new MyCurrency();
$active_currency = $currency->getCurrencyCode();
1
  • Please award the green tick to your own answer so that the Community will stop bumping this question to the top of the unresolved list.
    – mickmackusa
    Dec 5, 2021 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.