an
groups-icon

Changing a variable function to a global function

Wait a minute... This content is very very old. We no longer sell or support this theme version. New Topics
  • Version 9
    Jordan Alexander
    0 points
    Beginner

    Hey guys,

    I have read the codex guides and i am still a little confused on changing my variable function to have global output

    [code title=””]function getPricebs($url) {
    $decode = file_get_contents($url);
    return json_decode($decode, true);
    }

    $btcbsUSD = getPricebs(‘https://www.bitstamp.net/api/ticker/’);
    $btcbsPrice = $btcbsUSD[“last”];
    $btcbsVol = $btcbsUSD[“volume”]; // added line for volume here
    $btcbsDisplay = round($btcbsPrice, 2);
    $btcbsVol = round($btcbsVol, 2);[/code]

    This code is grabbing rates from a table. I’d like the outputs $btcbsDisplay and $btcbsVol to be global so I can access them from any page with a quick reference to the variable…. It seems reletively easy, as the guide suggest to define the variables outside the function but i am not exactly sure which ones i need to define for my case.

    Thank you!

    March 10, 2015 at 5:53 pm
  • Lee Robertson
    0 points
    Beginner
    Members Only Content

    This reply is for PremiumPress customers only.

    Login Now
    March 10, 2015 at 7:07 pm
  • Jordan Alexander
    0 points
    Beginner
    Members Only Content

    This reply is for PremiumPress customers only.

    Login Now
    March 10, 2015 at 7:10 pm
  • Jordan Alexander
    0 points
    Beginner
    Members Only Content

    This reply is for PremiumPress customers only.

    Login Now
    March 11, 2015 at 6:53 am

215

Views

3

Replies