Jump to content
Fórum Script Brasil
  • 0

Atribuir valores ao array


Question

boa tarde , estou iniciando a muito pouco tempo no php, e estou testando uma aplicação de atribuir valores a um array... porque depois vou adaptar a minha pagina, mas já tentei de tudo e não consigo... por favor alguém consegue me ajudar.... grata

 

<?php
$formacao = array(array('inicio' => 2006),
                  array('inicio' => 2013)
                 );
 
?>
 
<html>
  <head>
      <title></title>
  </head>
  <body>
 
  
       <h2>Formação:</h2>
 
      <?php foreach ($formacao as $curso): ?>
          <p><?= $curso['inicio']  ?></p>
      <?php endforeach?>
 
  <form>
            <fieldset>
                <legend>acrescentar mais uma data ao array</legend>
                <label>
                    tarefa: <input type="text" name="ano" />
                </label>
                <input type="submit" value="cadastrar" />
            </fieldset>
        </form>
 
        <?php
                 //* não CONSIGO ADICIONAR MAIS UM ITEM AO ARRAY ?????????????????
 
                if (isset($_POST['ano']))
                    {
                      array_push($formacao = array(array('inicio' => $_POST['ano']))); 
                          }
 
        ?>
 
        <h2>ADICIONADOS:</h2>
 
            <?php foreach ($formacao as $curso): ?>
                <p><?= $curso['inicio']  ?></p>
            <?php endforeach?>

 
Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Cloud Computing


  • Forum Statistics

    • Total Topics
      149421
    • Total Posts
      645924
×
×
  • Create New...