Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can we define the index of array in foreach loop for adding/dividng two different array values
    primarykey
    data
    text
    <p>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</p> <pre><code> &lt;?php if (isset($_POST['submit'])) { $data_t1 = $_POST['t1']; foreach ($data_t1 as $key =&gt; $value) { echo 'T1: ' . $value . '&lt;br /&gt;'; echo 'T2: ' . $_POST['t2'][$key] . '&lt;br /&gt;'; echo 'T3: ' . $_POST['a1'][$key] . '&lt;br /&gt;'; echo 'Username: ' . $_POST['username'][$key] . '&lt;br /&gt;&lt;br /&gt;'; } $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); ?&gt; </code></pre> <p>now i want these array values to be used for further computation <pre><code>echo "Measuring Efficiency "; echo "&lt;table border='1' align='center'&gt; &lt;tr&gt; &lt;th&gt;Inputs&lt;/th&gt; &lt;th&gt;A&lt;/th&gt; &lt;th&gt;B&lt;/th&gt; &lt;th&gt;C&lt;/th&gt; &lt;/tr&gt;"; echo "&lt;tr&gt;"; 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 "&lt;td&gt;" ."Room Size/Consumption". "&lt;/td&gt;"; echo "&lt;td&gt;".$r. "&lt;/td&gt;"; echo "&lt;td&gt;".$fr. "&lt;/td&gt;"; echo "&lt;td&gt;".$br. "&lt;/td&gt;"; echo "&lt;/tr&gt;"; echo "&lt;tr&gt;"; } ? </code></pre> <p>how can i define the index of array for division of elements of two array</p> <p>my result is</p> <p>$data_t1 [12 12] $data_t4 [1.44 4.32] $data_t2 [2 4] $data_t3 [2 3]</p> <p>i want to divide 12/1.44,2/1.44 2/1.44 n 12/4.32 4/4.32 3/4.32</p> <p>how can i do ths</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload