Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

188
Visualizações
Dynamic Input Fields from PHP Array

I've been trying to wrap my head around this for the last week or so, but really need some guidance.

I need to create dynamic form fields from PHP arrays. The PHP arrays vary in size, but they are always very simple arrays.

I'd like to be able to create the # of input fields by the number of items in the array, and populate the input fields with the array data.

The array data will look like the below (2 examples).

Array
(
    [0] => 19001.WAV

    [1] => 19307.WAV

    [2] => 19002.WAV

    [3] => 19308.WAV

    [4] => 19003.WAV

    [5] => 19009.WAV

    [6] => 19004.WAV

    [7] => 19310.WAV

    [8] => 19005.WAV

    [9] => 19311.WAV

    [10] => 19009.WAV

    [11] => 19307.WAV

    [12] => 19010.WAV

    [13] => 19308.WAV

    [14] => 19013.WAV

    [15] => 19309.WAV

    [16] => 19015.WAV

)

Or:

Array
(
    [0] => 101.WAV

    [1] => 101.WAV

    [2] => 102.WAV

    [3] => 102.WAV

    [4] => 103.WAV

    [5] => 103.WAV

)

I just don't even really know what direction to go.

about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

If you just want to render values use foreach:

<?php 
   foreach($array as $item) {
      echo '<input type="text" name="data[]" value="'. $item .'">'
   }
?>
about 4 years ago · Santiago Trujillo Relatório

0

Please refer foreach

foreach ($arr as $value) {
    echo "<input name='data[]' value='$value'> <br />";
}
about 4 years ago · Santiago Trujillo Relatório

0

Not a PHP programmer but I think it should go along the lines of:

<?php
reset($Array);
foreach ($arr as $key => $value) {
    echo "<input name='data[]' id='$key' value='$value'></input>\n";
}
?>

Hope it helps.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda