doddsey_65 Posted May 29, 2010 Share Posted May 29, 2010 Hi, I am trying to use preg_replace on a database column called content. This column contains some html code and within is several img tags. What i want to do is replace style="width: xxxpx; to style="width: 100px;. Here is the code i tried but it didn't work. Any ideas? $content = preg_replace('/(width:)=("[^"]*")/i', 'width: 100', $content); Link to comment https://forums.phpfreaks.com/topic/203315-using-preg_replace/ Share on other sites More sharing options...
teynon Posted May 30, 2010 Share Posted May 30, 2010 preg("@(width:[\s]*)([^p]*)(px)@i", "{$1}100{$3}", $content); I haven't tested it. Link to comment https://forums.phpfreaks.com/topic/203315-using-preg_replace/#findComment-1065207 Share on other sites More sharing options...
doddsey_65 Posted May 30, 2010 Author Share Posted May 30, 2010 sorry but i get a 500 error when using the code Link to comment https://forums.phpfreaks.com/topic/203315-using-preg_replace/#findComment-1065209 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.