Yes, I made a mistake in the first sentence.

The code is :
[...]

foreach ($equipos as $key => $val){

echo "<tr><td>";
echo "1" . "</td><td>";  // I would like to add the counter here reeplacing
"1"
print "<input type=\"radio\" name=$key value=\"l\" />" . "</td><td>";
echo $key . "</td><td>";
print "<input type=\"radio\" name=$key value=\"e\" />" . "</td><td>";
echo $val . "</td><td>";
print "<input type=\"radio\" name=$key value=\"b\" />" . "</td><td>";
}

?>

I use the array to generate the name of the radio and so on. However I had
problems with the counter.

Thanks


2007/11/15, Stut <[EMAIL PROTECTED]>:
>
> Juan Marcelo Rodríguez wrote:
> > I'm working with an associative array, and generating its data a form. I
> use
> > foreach to loops the contents of the array and echo to print the table
> and
> > the data. Everything goes well, however I would like to add a counter to
> > print the row's number.
> >
> > The question : Am I able to add a counter within foreach to print the
> row
> > number in each row using echo ?. I tried a few things but I couldn't.
>
> The mind boggles when wondering what you tried.
>
> $counter = 1;
> foreach ($array as $val)
> {
>         // Do your stuff here
>
>         // Increment the counter
>         $counter++;
> }
>
> -Stut
>
> --
> http://stut.net/
>

Reply via email to