eval.in

Paste #83247

PHP — PHP 5.5.1, pasted 1 year ago

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<?php 
$data = array(
array("Factor 1",16500,10000,100,100),
array("Factor 2",3000,1209,800,2765),
array("Factor 3 3",0,1000,1000,1000),

);
$aa = array("Factor 4",($data[0][1]-$data[1][1]),($data[0][2]-$data[1][2]),($data[0][3]-$data[1][3]),$data[0][4]-$data[1][4]);
array_push($data,$aa);
echo '<table width="300" border="0" cellspacing="0" cellpadding="0">';
foreach($data as $dat){
   echo ' <tr>
    <td width="95">'.$dat[0].'</td>
    <td width="15%">'.$dat[1].'</td>
    <td width="15%">'.$dat[2].'</td>
    <td width="15%">'.$dat[3].'</td>
    <td width="15%">'.$dat[4].'</td>
  </tr>';
}
echo '</table>';

Program Output

<table width="300" border="0" cellspacing="0" cellpadding="0"> <tr>
    <td width="95">Factor 1</td>
    <td width="15%">16500</td>
    <td width="15%">10000</td>
    <td width="15%">100</td>
    <td width="15%">100</td>
  </tr> <tr>
    <td width="95">Factor 2</td>
    <td width="15%">3000</td>
    <td width="15%">1209</td>
    <td width="15%">800</td>
    <td width="15%">2765</td>
  </tr> <tr>
    <td width="95">Factor 3 3</td>
    <td width="15%">0</td>
    <td width="15%">1000</td>
    <td width="15%">1000</td>
    <td width="15%">1000</td>
  </tr> <tr>
    <td width="95">Factor 4</td>
    <td width="15%">13500</td>
    <td width="15%">8791</td>
    <td width="15%">-700</td>
    <td width="15%">-2665</td>
  </tr></table>

OK (0.012 sec real, 0.012 sec wall, 14 MB, 47 syscalls)

Fork