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