title: pass associative array into php function
body: <p>how to pass an associative array into php functions? i tried the code below but its not working. please help me or atleast give advice.
  thank you so much.</p>
  
  <pre><code>addrecord.php
  require 'class.php';
  $fields = array(
  'strname' =&gt;$name,
  'strdescript' =&gt;$strdescript,
  'straction' =&gt;$straction
  );
  $addRecord = new Record();
  $addRecord-&gt;addRecord($fields);
  
  
  class.php
  class Record{
  public $db, $sql,$stmt;
  public function __construct(){
  $this-&gt;db = new connection();
  $this-&gt;db = $this-&gt;db-&gt;dbConnect();
  }
  public function addRecord($fields){
  $this-&gt;sql =
  "INSERT INTO user
  (name,description,action)
  VALUES
  (?,?,?)"
  $this-&gt;stmt = $this-&gt;db-&gt;prepare($this-&gt;sql);
  $this-&gt;stmt-&gt;bindParam(1,{$fields['strname']},PDO::PARAM_STR);
  $this-&gt;stmt-&gt;bindParam(2,{$fields['strdescript']},PDO::PARAM_STR);
  $this-&gt;stmt-&gt;bindParam(3,{$fields['straction']},PDO::PARAM_STR);
  $this-&gt;stmt-&gt;execute();
  if($this-&gt;stmt-&gt;rowCount==1){
  echo "&lt;script&gt;alert('blah.. blah.. blah.')&lt;/script&gt;";
  }else{ 
  echo "&lt;script&gt;alert('blah.. blah.. blah.')&lt;/script&gt;";
  }//EndIf
  }//EndFunction
  </code></pre>