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
969 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
0 answers

How do I link a JavaScript file to a HTML file?

How should a JavaScript file be linked ...READ MORE

Jul 21 in HTML by Ashwini
• 2,760 points
44 views
0 votes
0 answers

How to do calculations in HTML forms using JavaScript?

I'm developing a straightforward app that multiplies ...READ MORE

Jul 26 in HTML by Tejashwini
• 2,860 points
448 views
0 votes
1 answer

How do I give text or an image a transparent background using CSS?

In order to ensure that your image ...READ MORE

answered Feb 8 in HTML by Rahul
• 9,680 points
297 views
0 votes
0 answers

How to insert spaces/tabs in text using HTML/CSS

how to add space in HTML except ...READ MORE

Jun 3 in HTML by Tejashwini
• 2,860 points
55 views
0 votes
0 answers

How to create a vertical line in HTML?

I need to create a vertical line ...READ MORE

Jul 4 in HTML by Tejashwini
• 2,860 points
39 views
0 votes
0 answers

How to replace innerHTML of a div using jQuery?

How could I replace the below code ...READ MORE

Jul 4 in HTML by Tejashwini
• 2,860 points
201 views
0 votes
0 answers

how to create a HTML5 video element without it being shown in the page?

how is it possible to dynamically create ...READ MORE

Jul 5 in HTML by Tejashwini
• 2,860 points
56 views
0 votes
0 answers

How to remove a underline from a link in HTML?

how to remove the underline from a ...READ MORE

Jul 5 in HTML by Tejashwini
• 2,860 points
79 views
0 votes
0 answers

How to play video in react.js using html video tag?

Can somebody explain why my video won't ...READ MORE

Jul 19 in HTML by Tejashwini
• 2,860 points
1,871 views
0 votes
0 answers

How to extract img src, title and alt from html using php?

I want to make a page listing ...READ MORE

Jul 21 in HTML by Ashwini
• 2,760 points
47 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP