title: PHP - update a single dimensional array (by adding or subtracting values from key values)
body: <p>For an array like: </p>
  
  <pre><code>Array1 ( [a] =&gt; 1 [b] =&gt; 2 [c] =&gt; 7 [d] =&gt; )
  </code></pre>
  
  <p>I would like to update certain values if keys with variable match. </p>
  
  <p>For example, I am have two variables (a=0.5 and c=0.25). I may also have one or more than two variables which would need to be added to the array.</p>
  
  <p>In the case where I have two variables (a=0.5 and c=0.25). </p>
  
  <p>Can one update the array by adding the proper variable to its corresponding key in the array?</p>
  
  <p>End result:</p>
  
  <pre><code>Array1 ( [a] =&gt; 1.5 [b] =&gt; 2 [c] =&gt; 7.25 [d] =&gt; )
  </code></pre>
  
  <p>Can't think of a way to add values to original array (be from single array, multidimensional array or variables where the key match). I am a newbie to adding or updating array's key value, and am super stuck at these right now. Trying all kinds of things. Thank you! </p>
  
  <p>PS. I am not playing around with converting the original array to variables, perform the math, then convert back again to single dimensional array, but it will not do since the array may have unique keys every time... hmmm...</p>