ibab Posted March 19, 2011 Share Posted March 19, 2011 I've been trying to go around with str_replace to replace numbers with words. I have a database which has table actions. The actions are saved in numbers from 0 to 20. I'd need to get something to replace the numbers with words to explain what actions these are. I've tried using this. $action1 = str_replace("5", "Command", "action1"); But that doesn't work. Not even 100% sure if that is even correct, because I am new to the str_replace thing anyway. Could someone help me with this, please? Quote Link to comment https://forums.phpfreaks.com/topic/231081-replacing-multiple-numbers-with-words/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 19, 2011 Share Posted March 19, 2011 The 3rd parameter would need to be your $action1 variable and the first two parameters would need to be arrays with matching entries for all 21 pairs of values/words. Quote Link to comment https://forums.phpfreaks.com/topic/231081-replacing-multiple-numbers-with-words/#findComment-1189447 Share on other sites More sharing options...
ibab Posted March 19, 2011 Author Share Posted March 19, 2011 Could you give me an example of how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/231081-replacing-multiple-numbers-with-words/#findComment-1189451 Share on other sites More sharing options...
PFMaBiSmAd Posted March 19, 2011 Share Posted March 19, 2011 See the "You should eat fruits, vegetables, and fiber every day." example at this link - http://us.php.net/str_replace Quote Link to comment https://forums.phpfreaks.com/topic/231081-replacing-multiple-numbers-with-words/#findComment-1189454 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.