i have variable which contains this html string. i want change current tag ending > to required>. its really hard for me understand preg_replace so please write me how i must build correct regex expression.
$htmlVariable =' <div class="outer required">
<div class="form-group af-inner">
<label class="sr-only" for="name">~name~</label>
<input type="text" name="name" id="name" placeholder="~Name~" value="" size="30" data-toggle="tooltip" title="" class="form-control placeholder" >
</div>
</div>
<div class="outer required">
<div class="form-group af-inner">
<label class="sr-only" for="email">~mail~</label>
<input type="text" name="email" id="email" placeholder="~Email~" value="" size="30" data-toggle="tooltip" title="" class="form-control placeholder" >
</div>
</div>';
$out = preg_replace("<input name=email (>)","required>",$htmlVariable);
I trying change input ending > to required> if this input contains name with value email.**
this is important for me. thanks