I can't get my head around this.
I have a csv-file containing companynames and a certain value.
I run a script that get's the companyname and value from the csv.
A company can contain multiple values.
Here's what it looks like
[company1][123]
[company1][65456]
[company1][435]
[company1][234235]
[company2][65464]
[company2][53543]
What I want to do is get every value from every separate company and calculate the sum of all values from that specific company.
So I tried this:
foreach($data as $companies){
$company = $companies['name'];
$value = $companies['value'];
if ($company == 'company1'){
echo $value;
}
}
$data is the array with values from the csv
For testing purposes I have manually written a companies name in the if statement but this should be dynamically loaded from the $data-array.
After this it should calculate the sum of all values.
How can I accomplish this?