I have situation
$content = ' <input hspace="2" height="133" border="2" align="left" width="350" vspace="2" type="image" src="/userfiles/image/raghab_dhoj_pant(1).jpg">';
the height attribute and width attribute keeps changing. What i want is to fix this height to 150 and the width to 100, this string is a part of the field element of the MySQL database.
can any body suggest what will be the expression in preg_replace()? I can afford to use this separately for the width and height.
Thanks in advance
about preg_replace
Moderator: General Moderators
Re: about preg_replace
Is this what you want?
Code: Select all
$content = ' <input hspace="2" height="133" border="2" align="left" width="350" vspace="2" type="image" src="/userfiles/image/raghab_dhoj_pant(1).jpg">';
$pattern = array("/(height=\")(\d+)\"/","/(width=\")(\d+)\"/");
$replacement = array("height=\"150\"","width=\"100\"");
$output = preg_replace($pattern,$replacement,$content);
echo $output;