How to do calculation in PHP ?

0 votes

Morning,

I have a csv file which i need to perform calculation on that.

For instance, i have already split the string of the user into an array which is assign as follows:

[0] = Head

[1]= *

{2]=SubHead

array [1] [3] [5] ....will be Maths operators.

I want to retrieve all the values of the column Head and column SubHead in the csv and after that multiply it like:

Row 1 of Head multiply by Row 1 of Subhead

Row 2 of Head multiply by Row 2 of Subhead

Continue till the end of row_length.

I managed to display all the values of the two columns but having problem to do the calculation.

Can someone help?

Below is the image after running the code:

 

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>";

                    }                

                }

                

            }

            

}

          }

Thanks for your help.

6 days ago by vi
• 140 points
57 views
Hey,

Can you please elaborate what exactly you are trying to do?

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

0 votes
0 answers

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

Morning, I have a csv file and i ...READ MORE

6 days ago in HTML by anonymous
• 140 points
15 views
0 votes
1 answer

How to do a re-merge into another branch in git

Seems like you want to rebase your ...READ MORE

answered May 7, 2018 in Git & GitHub by DareDev
• 6,850 points
289 views
0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 17,090 points
575 views
0 votes
2 answers

How do we convert JSON to Map in Java

When you don't know structure of json. ...READ MORE

answered Oct 31, 2018 in Java by Sushmita
• 6,890 points
678 views
0 votes
1 answer

How to use bitcoin price as place holder in php?

You can do it by providing an ...READ MORE

answered Aug 21, 2018 in Blockchain by digger
• 26,660 points
61 views
0 votes
1 answer

How to get amount of bitcoins in php?

I’ve tried this code and it works: <?php function ...READ MORE

answered Aug 24, 2018 in Blockchain by slayer
• 29,270 points
84 views
0 votes
1 answer

Which package is used to do data import in R and Python and How do you import SAS data?

We can do data import using multiple ...READ MORE

answered Aug 24, 2018 in Data Analytics by Anmol
• 3,680 points
60 views
0 votes
1 answer

How to create Bitcoin Address in PHP?

You need to understand that Bitcoin address and ...READ MORE

answered Aug 27, 2018 in Blockchain by Perry
• 17,090 points
808 views
0 votes
2 answers

How do we convert only the second letter of every word in a string to uppercase ?

The following code will perform your desired ...READ MORE

answered Aug 28, 2018 in Java by curious
• 560 points
198 views