title: PHP - Editing multiple array values (if they exist)
body: <p>I have a multidimensional array. I need to search it for a specific range of values, edit those values and return the edited data.</p>
  
  <p>Example array:</p>
  
  <pre><code>array(3) {
    ["first"]=&gt;
    array(1) {
      [0]=&gt;
      string(4) "baz1"
    }
    ["second"]=&gt;
    array(1) {
      [0]=&gt;
      string(4) "foo1"
    }
    ["third"]=&gt;
    array(1) {
      [0]=&gt;
      string(4) "foo2"
    }
  </code></pre>
  
  <p>Now I want to find any values that match foo (foo1 and foo2 in the example array), insert "-bar" into them (foo-bar1, foo-bar2) and return that value. What are the best ways to approach this? </p>
  
  <p><em>EDIT</em> I should have mentioned that foo could actually be anythingfoo (ex. examplefoo1, somethingelsefoo2, blahblahfoo3). I think this rules out str_replace.</p>