# Calculate Costs for Buildings

I have the following arrays:

[costs] => Array (
 => Array (
[value] => 600
[name] => Wood
)
 => Array (
[value] => 200
[name] => Stone
)
 => Array (
[value] => 800
[name] => Iron
)
 => Array (
[value] => 300
[name] => Gold
)
)

Array (
 => Array (
[balance] => 70636.86
)
 => Array (
[balance] => 70636.86
)
 => Array (
[balance] => 70636.38
)
 => Array (
[balance] => 141072.77
)
)


I want to check if the second array enough resources to spend from the first array and if one of the values from the first array is not = or less. Can someone help me out?

What I've tried so far:

for($i = 0;$i < 4; $i++) {$balance = $this->listResources[$i]['balance'];
if($balance >=$this->buildingCosts[$i]['value'])$this->listBuildings[$i][$this->listKey]['status'][$balance] = '1'; else$this->listBuildings[$i][$this->listKey]['status'] = '0';
}


What I'm trying to find out is to see if I have enough resources in array to spend ( values that I need are found in costs )

Your question is extremely cryptic (we can only vaguely guess, for example, that $this->listKey in some way refers to the building type you're trying to create, and some of your sentences are unintelligible), but I suspect you mean something like: for($i = 0; $i < 4;$i++) {
$balance =$this->listResources[$i]['balance'];$this->listBuildings[$this->listKey]['status'][$i] = ($balance >=$this->buildingCosts[$i]['value']); }  That populates $this->listBuildings with status arrays that map resource index numbers to booleans indicating whether or not the available quantity of that resource is sufficient.