How to do calculation in PHP using a csv file for retrieving data?

0 votes

Morning,

I have a csv file and i want to do calculation. At first, i have already split the string into array.

I have retrieve two columns in my csv namely Head and SubHead.

I want to do the calculation of Head and SubHead in such format:

Row 1 of head multiply by Row 1 of SubHead

Continue until end of row.

if($out[1]=="*"||$out[1]=="/"||$out[1]=="+"||$out[1]=="-"){

  

  $out1=$out[1];

  if($out1=="*"){

    $first=$out[0];

    $second=$out[2];

        foreach ($mycsv[0] as $key => $value) {

     if (strcasecmp($value, $first) == 0) {

                for ($row=0; $row < $row_length; $row++) { 

                    if ($row == 0) {

                        echo "<tr>";

                        echo "<th colspan=100%>" . $mycsv[0][$key] . "</th>";

                        echo "</tr>";

                    } else {

                      $yes=$mycsv[$row][$key];

                        echo "<td>" . $yes . "</td>";

                    }                

                }

                

            }

                

            if (strcasecmp($value, $second) == 0) {

                for ($row=0; $row < $row_length; $row++) { 

                    if ($row == 0) {

                        echo "<tr>";

                        echo "<th colspan=100%>" . $mycsv[0][$key] . "</th>";

                        echo "</tr>";

                    } else {

                      $yes2=$mycsv[$row][$key];

                      echo "<td>" . $yes2 . "</td>";

                    }                

                }

                

            }

            

}

          }

Note: $out[1] is the Math operators.

Thanks for helping.

6 days ago in HTML by anonymous
• 140 points
15 views
Hi,

It will be very helpful if you tell what exactly you are trying to get?

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In HTML

0 votes
1 answer

How can i create simple register form using html and css?

Html5 contains lots of elements using which ...READ MORE

answered Jan 31 in HTML by Niroj
• 3,230 points
41 views
0 votes
1 answer

How to Identify Web Element( Button) when there are multiple buttons without any ID

Hi Gangadhar, Do you need the HTML code to ...READ MORE

answered Feb 10 in HTML by Roshni
• 400 points
18 views
–1 vote
1 answer

How to read a csv file stored in Amazon S3 using csv.DictReader

The code would be something like this: import ...READ MORE

answered Oct 25, 2018 in AWS by Archana
• 5,600 points
14,813 views
0 votes
1 answer

How do I convert data frame to csv file in R?

Hey @Ali, its very simple one line ...READ MORE

answered Nov 21, 2018 in Data Analytics by Maverick
• 10,800 points
130 views
0 votes
1 answer
0 votes
1 answer

How to assign a data in a variable in to excel file?

System -> File -> Workbook -> Append ...READ MORE

answered May 22, 2018 in RPA by wrecker
• 3,110 points
136 views
0 votes
2 answers

How to skip headers when reading a CSV file in S3 and creating a table in AWS Athena?

Thanks for the answer. This should be clear ...READ MORE

answered Aug 14, 2019 in AWS by athenauserz
2,128 views
0 votes
1 answer

How to download the latest file in a S3 bucket using AWS CLI?

You can use the below command $ aws ...READ MORE

answered Sep 6, 2018 in AWS by Archana
• 4,150 points
6,267 views
0 votes
1 answer

How do you wait on a Task Scheduler task to finish in a batch file or C#?

From batch file, query the task status, ...READ MORE

answered Sep 24, 2018 in Azure by club_seesharp
• 3,450 points
121 views
0 votes
1 answer

How to write a file in HDFS using Java Programming language?

Define the HADOOP_CONF_DIR environment variable to your Hadoop configuration ...READ MORE

answered Sep 28, 2018 in Big Data Hadoop by Frankie
• 9,810 points
502 views