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
1,453 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, 2022 in HTML by Ashwini
• 5,430 points
438 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, 2022 in HTML by Tejashwini
• 3,820 points
1,575 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, 2022 in HTML by Rahul
• 9,680 points
1,231 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, 2022 in HTML by Tejashwini
• 3,820 points
374 views
0 votes
0 answers

How to create a vertical line in HTML?

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

Jul 4, 2022 in HTML by Tejashwini
• 3,820 points
657 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, 2022 in HTML by Tejashwini
• 3,820 points
721 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, 2022 in HTML by Tejashwini
• 3,820 points
475 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, 2022 in HTML by Tejashwini
• 3,820 points
496 views
0 votes
2 answers

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

This is a solution: import Video from "..Videos/video1.mp4" class ...READ MORE

answered May 21, 2023 in HTML by Renie
7,253 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, 2022 in HTML by Ashwini
• 5,430 points
590 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