title: Replace attribute value in an HTML string using PHP
body: <p>I have a filter hook that passes a string of HTML. An example string might be:</p>
  
  <pre><code>'&lt;input type="text" value="4893" /&gt;'
  </code></pre>
  
  <p>The string is passed to the filter hook:</p>
  
  <pre><code>add_filter( 'html_filter', 'my_html_filter', 10, 1 );
  function my_html_filter( $html ) {
  
      $html =     &lt;--- REPLACE VALUE ATTRIBUTE HERE
  
      return $html;
  }
  </code></pre>
  
  <p>What I need to do inside of <code>my_html_filter()</code> is replace the value of <code>value=""</code> and I'm not sure how to isolate this in <code>$html</code>. As a random example, say <code>$html</code> is passed as:</p>
  
  <pre><code>'&lt;input type="text" value="345" /&gt;'
  </code></pre>
  
  <p>and I need to change it to:</p>
  
  <pre><code>'&lt;input type="text" value="14972" /&gt;'
  </code></pre>
  
  <p>How would I do this? A combination of str_replace and a regex expression?</p>