title: php can't add data to array
body: <p>here's a question : After entering some data about students, i need to print them in top side of the page (form one). I've managed to print data for single student, but i can't make it to store data in $studenti array, so that it will print data for all students.
  here's code that i used(i forgot to mention, i need to use sessions for this):</p>
  
  <pre><code>    &lt;?php
  session_start();
  
  $_SESSION['aindex'] = $_POST['index'];
  $_SESSION['aime']= $_POST['ime'];
  $_SESSION['aprosek'] = $_POST['prosek'];
  
  //if ($index != "" &amp;&amp; $ime != "" &amp;&amp; $prosek !="")
  //{
  // = $index;
   //= $ime;
   //=$prosek;
  
  //}
  
  //print ($_SESSION['aindex']);
  function inicijalizacija()
  {
      $studenti = array ();
      $ind = $_SESSION['aindex'];
      $im = $_SESSION['aime'];
      $pr = $_SESSION['aprosek'];
  
      $studenti[$ind]["ime"] = $im;
      $studenti[$ind]["prosek"] = $pr;
  
  return $studenti;   
  }
  
  function dodaj($studenti)
  {
  $studenti[$_SESSION['aindex']]["ime"] = $_SESSION['aime'];
  $studenti[$_SESSION['aindex']]["prosek"] = $_SESSION['aprosek'];
  
  return $studenti;
  }
  
  function prikazi($studenti) //ovde u argumentu treba $studenti
  {
  
  print ("&lt;h2&gt; Lista Studenata: &lt;/h2&gt;");
  foreach ($studenti as $ind =&gt; $student)
  {
  if (empty($ind))
      continue;
  $n = $student["ime"];
  $p = $student["prosek"];
  print ("Index: " . $ind . " " . "Ime: " . $n . " " .  "Prosek: " . $p );
  
  
  }
  print("&lt;hr size ='1'&gt;");
  
  //Forma dodavanja
  
  print (" &lt;form action = 'index.php' method = 'post' &gt;");
  print ( " Indeks:&amp;nbsp   &lt;input type = 'text' name = 'index' /&gt;");
  print(" &lt;/br&gt;");
  print ( " Ime:&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp   &lt;input type = 'text' name = 'ime' &gt;");
  print(" &lt;/br&gt;");
  print ( " Prosek : &lt;input type = 'text' name = 'prosek' /&gt;");
  print(" &lt;/br&gt;");
  print (" &lt;input type = 'submit' value = 'Dodaj' name = 'Dodaj' /&gt;");
  }
  
  
  
  
  $studenti = inicijalizacija();
  ?&gt;
  
  
  &lt;html&gt;
      &lt;head&gt; &lt;title&gt; pokusaj &lt;/title&gt; &lt;/head&gt;
      &lt;body&gt;
      &lt;?php
  
      prikazi($studenti);
      dodaj($studenti);
      ?&gt;
  
      &lt;/body&gt;
  
  
  
  &lt;/html&gt;
  </code></pre>