2
In a bow tie foreach I need to increment a counter to set the tabindex of the form fields, so that the result is:
<input type="text" name="endereco[0][cep]" value="00000-000" tabindex="1">
<input type="text" name="endereco[0][rua]" value="Rua XXXX" tabindex="2">
<input type="text" name="endereco[1][cep]" value="11111-111" tabindex="3">
<input type="text" name="endereco[1][rua]" value="Rua YYYY" tabindex="4">
What do I have:
<?php
$i = 0;
foreach ($enderecos as $endereco) {
?>
<input type="text" name="endereco[<?php echo $i?>][cep]" value="<?php echo $endereco['cep']; ?>" tabindex="">
<input type="text" name="endereco[<?php echo $i?>][rua]" value="<?php echo $endereco['rua']; ?>" tabindex="">
<?php
$i++;
}
?>
I don’t know how I can increment a counter to set the tabindex
– Eron Venter
It seems to me a case of using a for, not foreach.
– Bacco