Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My only suggestion would be this one</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;a&lt;/td&gt; &lt;td&gt;b&lt;/td&gt; &lt;td&gt;c&lt;/td&gt; &lt;td&gt;d&lt;/td&gt; &lt;/tr&gt; &lt;?php $fhdrop2 = fopen("rc.csv", "r"); while (!feof($fhdrop2) ) { $at2[] = fgetcsv($fhdrop2, 1024); } $fhdrop = fopen("ac.csv", "r"); while (!feof($fhdrop) ){ $at = fgetcsv($fhdrop, 1024); ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $at[0]; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $at[1]; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo number_format($at[1]*$at2[0][1],2); ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo number_format($at[1]*$at2[1][1],2); ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;/table&gt; </code></pre> <p>This should not optimize in speed but it should save some memory for bigger ac.csv files, because you do not need to create a big array. But i do not think you could optimize speed here. I hope someone can provide a better answer.</p> <p><strong>EDIT #01</strong> Here is little more flexible loop</p> <pre><code>&lt;tr&gt; &lt;td&gt;&lt;?php echo $at[0] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $at[1] ?&gt;&lt;/td&gt; &lt;?php for($i = 0; $i &lt; sizeof($at2); $i++){ ?&gt; &lt;td&gt;&lt;?php echo number_format($at[1]*$at2[$i][1],2) ?&gt;&lt;/td&gt; &lt;?php } ?&gt; &lt;/tr&gt; </code></pre> <p>With this one your rc.csv can store more than 2 Values to multiply. Not an speed or memory optimization but you will save code and time if you try to scale your functions/loops. </p> <p><strong>EDIT #02</strong> I tried scrowler's approach and would suggest this one because of the logic/mark-up separation. The side effects are more use of Memory and a slightly slower script speed but it isn't significant (the speed). </p> <p>Hope this will help</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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