fork download
  1. <?php
  2.  
  3. $i = 0;
  4. $j = 0;
  5. $enderecos = array(array('cep' => '00000-00', 'rua' => 'Rua XXXX'), array('cep' => '11111-111', 'rua' => 'Rua YYYY'), array('cep' => '22222-222', 'rua' => 'Rua ZZZZ'), array('cep' => '33333-333', 'rua' => 'Rua WWWW'));
  6.  
  7. foreach ($enderecos as $endereco) {
  8. ?>
  9. <input type="text" name="endereco[<?php echo $i?>][cep]" value="<?php echo $endereco['cep']; ?>" tabindex="<?php echo ($j+1) ?>">
  10. <input type="text" name="endereco[<?php echo $i?>][rua]" value="<?php echo $endereco['rua']; ?>" tabindex="<?php echo ($j+2) ?>">
  11. <?php
  12. $i++;
  13. $j+=2;
  14. }
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
<input type="text" name="endereco[0][cep]" value="00000-00" 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">
<input type="text" name="endereco[2][cep]" value="22222-222" tabindex="5">
<input type="text" name="endereco[2][rua]" value="Rua ZZZZ" tabindex="6">
<input type="text" name="endereco[3][cep]" value="33333-333" tabindex="7">
<input type="text" name="endereco[3][rua]" value="Rua WWWW" tabindex="8">