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.

Feb 11, 2020 in HTML by anonymous
• 140 points
576 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 to align a <div> to the middle (horizontally/width) of the page?

Hello Kartik, position: absolute and then top:50% and left:50% places the top edge ...READ MORE

answered Apr 23, 2020 in HTML by Niroj
• 82,760 points
114 views
0 votes
1 answer

unable to load image file using <img> tag

This error means that file was not ...READ MORE

answered Oct 7, 2020 in HTML by Niroj
• 82,760 points
796 views
+1 vote
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, 2020 in HTML by Niroj
• 82,760 points
2,126 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, 2020 in HTML by Roshni
• 10,480 points
517 views
0 votes
1 answer

I've a query for <form>tag

That might be because button inside form ...READ MORE

answered Nov 2, 2020 in HTML by sindhu
111 views
0 votes
0 answers
+1 vote
2 answers

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,640 points
39,413 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,840 points
1,398 views
0 votes
2 answers
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
321 views