Jump to content

[SOLVED] 1 Array + 1 Function + 1 Calculation = 1 Big Headache


tcollie

Recommended Posts

Okay, I've created a function to calculate the max amount that can be purchased for a market system.  It looks like this:

 

function market_max($cash)
  {
  include('includes/_config.php');
  $max['product_01'] = $cash/$config['product_01'];
  return $max;
  }

 

And my includes/_config.php code:

$config['product_01'] = 1;

 

And my script:

$cash = 1000;
market_max($cash);
print_r($max);

This doesn't output anything.  But if I just code it outside the function like this, it works:

 

include('includes/_config.php');
$cash = 1000;
$max['product_01'] = $cash/$config['product_01'];
print_r($max);

Output:
Array ( [product_01] => 1000 )

 

Where am I going wrong???

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.