count data in foreach php code example
Example: php foreach count rows
<?php
$count = 0;
foreach( $names as $name){
$count = $count + 1;
echo "<td>".$count. "</td>
"<td>".$name. "</td>";
}
echo $count;
?>
<?php
$count = 0;
foreach( $names as $name){
$count = $count + 1;
echo "<td>".$count. "</td>
"<td>".$name. "</td>";
}
echo $count;
?>