Jump to content

Random Variable Problem


Clarkeez

Recommended Posts

Hey.. Weird problem

 

I'm trying to use information in an array inside a function, but when I call it, the information is not there.

 

Ill show you

 

<?php
    $c['guild'] = array('region' => 'eu', 'realm' => 'kazzak', 'name' => 'almost imba');

    function get_guild_api_url() {
$out = 'http://'.$c['guild']['region'].'.battle.net/api/wow/guild/'.$c['guild']['realm'].'/'.$c['guild']['name'].'';
return $out;
    }

    echo get_guild_api_url();
   // it shows http://.battle.net/api/wow/guild//
   // as you can see nothing from the array is there
?>

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/244456-random-variable-problem/
Share on other sites

Just because you defined $c outside the function does not mean it is available inside the function.

 

Since your function only needs the region, realm, and name, pass those three bits of information as arguments to get_guild_api_url():

function get_guild_api_url($region, $realm, $name) {

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.