Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

189
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

Please refer foreach

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

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda