title: Why my array element is re-declaring?
body: <p>I have declared static array $error whose elements are defining in function validate</p>
  
  <pre><code>static $error = array();
  
  if(!empty($_POST) &amp;&amp; validate())
  {
     $sql = mysql_query("INSERT INTO `table-name` SET category = " . $_POST['category'] . ", brand = " . $_POST['brand'] . ", product = '" . $_POST['p_name'] . "', location = " . $_POST['location'] . ", image = '" . $_POST['image'] . "', sku = '" . $_POST['sku'] . "'");            
  }
  
  function validate() 
  {
      if ((strlen($_POST['p_name']) &lt; 3) || (strlen($_POST['p_name']) &gt; 32)) 
      {
           $error["p_name"] = "Please enter Vendor name of 3 to 32 characters." ;
      }
      .
      .
      .
  }
  </code></pre>
  
  <p>but the problem is when i am using the updated $error element like $error['p_name'] in below html, it is showing undefined index p_name.</p>
  
  <pre><code>&lt;td&gt;
      &lt;?php if(isset($error["p_name"])){ ?&gt;&lt;span class="error"&gt;&lt;?php echo $error["p_name"]; ?&gt;&lt;/span&gt;&lt;?php } ?&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p>and when I print <code>$error['p_name']</code> element within validate function it get printed with updated value.</p>
  
  <p>Actually element - <code>$error['p_name']</code> in validate function is defining a new element rather than creating a new array element of predefined <code>$error</code> array.</p>