hello i want show paragraph with image from database. but i want delete inline style width image.
example :
<?php $prg = "hello this is paragragph and this is image 1
<img src='https://www.google.co.id/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png' style='width:150px;heigh:150px'>
this is text and this is image 2
<img src='http://www.bing.com/az/hprichbg/rb/HumpbackWhaleReunion_ROW11050338497_1366x768.jpg' style='width:150px;heigh:150px' ></p>";
echo $prg; ?>
i want delete width image in inline style.
this code result i want like this
<?php $prg = "hello this is paragragph and this is image 1
<img src='https://www.google.co.id/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png' style='heigh:150px'>
this is text and this is image 2
<img src='http://www.bing.com/az/hprichbg/rb/HumpbackWhaleReunion_ROW11050338497_1366x768.jpg' style='heigh:150px' ></p>";
echo $prg; ?>
here ya go - using regular expressions
<?php
$prg = "hello this is paragragph and this is image 1
<img src='https://www.google.co.id/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png' style='width:150px;heigh:150px'>
this is text and this is image 2
<img src='http://www.bing.com/az/hprichbg/rb/HumpbackWhaleReunion_ROW11050338497_1366x768.jpg' style='width:150px;heigh:150px' ></p>";
echo preg_replace("/width:[0-9]+[a-z]{2};?/i",'',$prg);
?>
showing regex is matching https://regex101.com/r/xE8gX7/1
You can also use str_replace()
$prg = "hello this is paragragph and this is image 1 <img src='https://www.google.co.id/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png' style='width:150px;heigh:150px'> this is text and this is image 2 <img src='http://www.bing.com/az/hprichbg/rb/HumpbackWhaleReunion_ROW11050338497_1366x768.jpg' style='width:150px;heigh:150px' ></p>";
$prg = str_replace("style='width:150px;heigh:150px'"," style='height:150px;'",$prg);