MarcusZ Posted August 22, 2009 Share Posted August 22, 2009 Hi! This script is supposed to shorten the sms-message to only a number. The function is not executed when running the script which gives me the same string that I inserted. What do I do wrong? <?php $sms = 'sunds nv1b 5'; function deleteSMS($delete_txt) { $sms = str_replace($delete_txt, '',$sms); } deleteSMS('sunds'); deleteSMS('nv1b'); deleteSMS(' '); echo $sms; ?> Quote Link to comment https://forums.phpfreaks.com/topic/171390-solved-function/ Share on other sites More sharing options...
ignace Posted August 22, 2009 Share Posted August 22, 2009 function deleteSMS(&$sms, $delete_txt) { $sms = str_replace($delete_txt, '',$sms); } or: function deleteSMS($delete_txt) { global $sms; $sms = str_replace($delete_txt, '',$sms); } Quote Link to comment https://forums.phpfreaks.com/topic/171390-solved-function/#findComment-903893 Share on other sites More sharing options...
MarcusZ Posted August 22, 2009 Author Share Posted August 22, 2009 thank you very much, used the second alternative. I need to do some reading on global and (&$sms, $delete_txt) Quote Link to comment https://forums.phpfreaks.com/topic/171390-solved-function/#findComment-903896 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.