Köprü öğe ile çok boyutlu Array

0 Cevap php

Aşağıda alternatif-satır renkleri ile bir tablo gibi göstermek için çok boyutlu bir dizi için benim kodudur.


<?php
$Mags = array(
 array(
'1', 'Krish','1977/03','V10', 'M3','March-77'
),

 array(
'2', 'Vansh','1978/09','V11', 'M9','Sept-78'
),


 array(
'3', 'Sushi','1981/07','V14', 'M7','July-81'
)

);
?>

<table id="fancytable"><tbody><thead>
<tr>
 <th>S.No</th>
 <th>Dedicate</th>
 <th>Vol.</th>
 <th>ID</th>
 <th>Month-Year</th>
</tr></thead>
<?php
$i=1;
foreach($Mags as $mag)
{
if($i % 2 == 0)
{
echo "<tr class='odd'>";
}
else
{
echo "<tr>";
}
 foreach($mag as $item)
 {
  echo "<td>$item</td>";
 }
 echo '</tr>';
$i = $i + 1;
}
?>
</tbody></table>

I dont want to give separate "key" for each item. because I am copying array items from an Excel "csv" file (i.e. each row with 6-columns) I want to show only 5-itmes per row. Item no."3" should be used as a relative URL (with base-url as "http://mydomain.com/") for Item no."2".

My question is : How do I have to use the "foreach" php-function ?

0 Cevap