AE117 Posted January 26, 2010 Share Posted January 26, 2010 What I am trying to do is take any number that is 3 chars in length and replace it with 400. I think you are suppose to use str_replace but I can seem to find the right way of doing what i want it to do. Can anyone help me out? Link to comment https://forums.phpfreaks.com/topic/189862-replace-any-string-of-numbers-with-400/ Share on other sites More sharing options...
JAY6390 Posted January 26, 2010 Share Posted January 26, 2010 $newstring = preg_replace('%\b\d{3}\b%', '400', $oldstring); That should do it Link to comment https://forums.phpfreaks.com/topic/189862-replace-any-string-of-numbers-with-400/#findComment-1001855 Share on other sites More sharing options...
AE117 Posted January 26, 2010 Author Share Posted January 26, 2010 You are awesome I had nothing even remotely close to that. Link to comment https://forums.phpfreaks.com/topic/189862-replace-any-string-of-numbers-with-400/#findComment-1001858 Share on other sites More sharing options...
JAY6390 Posted January 26, 2010 Share Posted January 26, 2010 lol no problem Link to comment https://forums.phpfreaks.com/topic/189862-replace-any-string-of-numbers-with-400/#findComment-1001859 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.