defeated Posted June 23, 2008 Share Posted June 23, 2008 Can I use wildcards in str_replace eg. can $replacing=str_replace("<p style='text-align:center;'>","<p>","$anyoldhtml"); be written as $replacing=str_replace("<p*>","<p>","$anyoldhtml"); ?? I want to reformat a whole load of text from tinyMce that is causing problems with my page validations.... plus there is just too much code created by tinyMce. Link to comment https://forums.phpfreaks.com/topic/111467-solved-string-replace-question/ Share on other sites More sharing options...
nashruddin Posted June 23, 2008 Share Posted June 23, 2008 Use regular expression instead. <?php /* replace all <p ...> with <p> */ $new_string = preg_replace("/<p[^>]*>/", "<p>", $old_string); ?> Link to comment https://forums.phpfreaks.com/topic/111467-solved-string-replace-question/#findComment-572226 Share on other sites More sharing options...
defeated Posted June 23, 2008 Author Share Posted June 23, 2008 That's great. Thanks. What is regex? Is it part of php? Where is a good place to read up on it? Link to comment https://forums.phpfreaks.com/topic/111467-solved-string-replace-question/#findComment-572342 Share on other sites More sharing options...
defeated Posted June 23, 2008 Author Share Posted June 23, 2008 oops... just saw that this post has been moved to the relevant place so ignore my questions.... I'll find it all from here! Thanks again. Link to comment https://forums.phpfreaks.com/topic/111467-solved-string-replace-question/#findComment-572347 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.