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); Quote 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. Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/203315-using-preg_replace/#findComment-1065209 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.