newbtophp Posted November 20, 2009 Share Posted November 20, 2009 Im doing the following, it works fine, but was wondering how'd I shorten the number of code, perhaps into 1 preg_replace? $code = str_replace('( ', '(', $code); $code = str_replace(' );', ');', $code); $code = str_replace(' )', ')', $code); $code = str_replace(' ( ', '(', $code); $code = str_replace(' ( ', '(', $code); $code = str_replace(' )', ')', $code); $code = str_replace(' )', ')', $code); $code = str_replace(' (', '(', $code); Quote Link to comment https://forums.phpfreaks.com/topic/182338-solved-shorten-up-code-to-preg_replace/ Share on other sites More sharing options...
nrg_alpha Posted November 20, 2009 Share Posted November 20, 2009 One method could probably involve an array using strtr. Quote Link to comment https://forums.phpfreaks.com/topic/182338-solved-shorten-up-code-to-preg_replace/#findComment-962210 Share on other sites More sharing options...
newbtophp Posted November 20, 2009 Author Share Posted November 20, 2009 One method could probably involve an array using strtr. cooool, thanks alot! Quote Link to comment https://forums.phpfreaks.com/topic/182338-solved-shorten-up-code-to-preg_replace/#findComment-962218 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.