title: Trouble deleting row of data from array. PHP + Javascript
body: <p>I have a screen like this:
  <a href="http://i.stack.imgur.com/EN03S.png" rel="nofollow">notifications example</a></p>
  
  <p>And it deletes the row, but only from the screen. Because if I refresh then it appears back again. I am not sure how to delete it from the actual array. 
  The array is taken out of a csv file- and I know how to add it back in etc. But what I don't know is deleting rows from the array. </p>
  
  <p>Heres what I have:</p>
  
  <pre><code>// Grabs the csv file (and its existing data)  and makes it into an array so the new data can be added to it.
  $Notifications = array();
  $lines = file('data/AdminNotifications.csv', FILE_IGNORE_NEW_LINES);
  foreach ($lines as $key =&gt; $value)
  {
      $Notifications[$key] = str_getcsv($value);
  }
  
  echo array2table(array_reverse($Notifications));
  
  
  // FUNCTION ---------------------------------------------------------------------
  
  //This converts an array to a table
  function array2table($array, $recursive = false, $null = '&amp;nbsp;')
  {
      // Sanity check
      if (empty($array) || !is_array($array)) {
          return false;
      }
  
      if (!isset($array[0]) || !is_array($array[0])) {
          $array = array($array);
      }
  
      // Start the table
      $table = "&lt;table&gt;\n";
  
      // The header
      $table .= "\t&lt;tr&gt;";
  
      // Take the keys from the first row as the headings
      foreach (array_keys($array[0]) as $heading) {
  
      }
  
      $table .= "&lt;/tr&gt;\n";
  
      // The body
      foreach ($array as $row) {
          $table .= "\t&lt;tr&gt;" ;
  
          foreach ($row as $cell) {
              $table .= '&lt;td&gt;';
  
              /*
              if($cell ==0 &amp;&amp; $heading==1){
              $cell = $cell.":  ";
          }
              */
  
              $details = $cell;
  
  
              // Cast objects
              if (is_object($cell)) { $cell = (array) $cell; }
  
              if ($recursive === true &amp;&amp; is_array($cell) &amp;&amp; !empty($cell)) {
                  // Recursive mode
                  $table .= "\n" . array2table($cell, true, true) . "\n";
              } else {
                  $table .= (strlen($cell) &gt; 0) ?
                      htmlspecialchars((string) $cell) :
                      $null;
              }
  
   $table .= '&lt;/td&gt;';
  
  
          }
              $table .= '&lt;td&gt;';
  
  
              $table .= '&lt;input type="submit" value="Delete" onclick="deleteRow(this)" name="delete"/&gt;';
  
  
              $table .= '&lt;/td&gt;';
  
  
  
          $table .= "&lt;/tr&gt;\n";
      }
  
      $table .= '&lt;/table&gt;';
      return $table;
  }
  
  
  //If the delete button is pressed, then it does this.
  if (isset($_POST['delete'])) {
  
  }
  
  ?&gt;
  
  //What happens when it is pressed. (This is javascript)
  &lt;script&gt;
  function deleteRow(btn) {
    var row = btn.parentNode.parentNode;
    row.parentNode.removeChild(row);
  
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Any help would be greatly appreciated. I am not too sure whether I can delete a row using javascript? Or in php and java...</p>
  
  <p>Thanks</p>