title: php - Add value with key to all the elements
body: <p>I've an array which is created by an mysql query result as below:</p>
  <pre><code>$result = $query-&gt;result_array(); 
  print_r($result); 
  
  Array ( 
  [0] =&gt; Array ( [productspec_id] =&gt; 40 [data] =&gt; ok ) 
  [1] =&gt; Array ( [productspec_id] =&gt; 88 [data] =&gt; reasonable  ) 
  [2] =&gt; Array ( [productspec_id] =&gt; 86 [data] =&gt; ) 
  )
  </code></pre>
  <p>I want to append the below two values with key to all the arrays:</p>
  <pre><code>$inq_id='67';
  $prod_id='76';
  </code></pre>
  <p>Below is the <strong>expected result</strong> which I need to use to insert into the database:</p>
  <pre><code>Array ( 
  [0] =&gt; Array ( [productspec_id] =&gt; 40 [data] =&gt; ok [inq_id] =&gt; 67 [prod_id] =&gt; 76 ) 
  [1] =&gt; Array ( [productspec_id] =&gt; 88 [data] =&gt; reasonable [inq_id] =&gt; 67 [prod_id] =&gt; 76 ) 
  [2] =&gt; Array ( [productspec_id] =&gt; 86 [data] =&gt; [inq_id] =&gt; 67 [prod_id] =&gt; 76 ) 
  )
  </code></pre>
  <p>I tried with <code>array_push</code> but not working as expected. Thanks in advance.</p>