hi everyone i fetch the array by using foreach loop now how can i define the index of different elements in array for futher computation like i want the element1 of array 1 to be divided by element1 of array 2 code of for each loop
now i want these array values to be used for further computation
how can i define the index of array for division of elements of two array
Code:
<?php
if (isset($_POST['submit'])) {
$data_t1 = $_POST['t1'];
foreach ($data_t1 as $key => $value) {
echo 'T1: ' . $value . '<br />';
echo 'T2: ' . $_POST['t2'][$key] . '<br />';
echo 'T3: ' . $_POST['a1'][$key] . '<br />';
echo 'Username: ' . $_POST['username'][$key] . '<br /><br />';
}
$data_t2 = $_POST['t2'];
$data_t3=$_POST['a1'];
$data_t4=$_POST['username'];
}
var_dump($data_t1);
var_dump($data_t2);
var_dump($data_t3);
var_dump($data_t4);
?>
Code:
echo "Measuring Efficiency ";
echo "<table border='1' align='center'>
<tr>
<th>Inputs</th>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>";
echo "<tr>";
foreach($data_t4 as $t4)
{
echo $t4; this display the values of array 4
}
foreach($data_t1 as $t1)
{
echo $t1;
$r=round(($t1/$t4),2);
$fr=round(($t1/$t4),2);
$br=round(($t1/$t4),2);
echo "<td>" ."Room Size/Consumption". "</td>";
echo "<td>".$r. "</td>";
echo "<td>".$fr. "</td>";
echo "<td>".$br. "</td>";
echo "</tr>";
echo "<tr>";
}
?>