cr-ispinternet Posted January 5, 2008 Share Posted January 5, 2008 Hi All, been toying with this for a while, but i need to do this because its affecting the sending of sms thorugh an sms gateway i need to be able to replace the 0 from $mobile_number with a 44 so basically well end up with this.. Original mobile: 07832128624 after str_replace or something like that 447832128624 had a quick go with it using str_replace and could get it to output thanks to any who can show me how to sort it. Alan Quote Link to comment https://forums.phpfreaks.com/topic/84592-solved-strip-a-0-from-a-mobile-number-and-add-44-instead/ Share on other sites More sharing options...
cr-ispinternet Posted January 5, 2008 Author Share Posted January 5, 2008 Sorted, you look long enough you always fine it :-) <? $mobile_number = "07832128624"; $mobile = str_replace("0", "44", "$mobile_number"); Print $mobile; ?> Quote Link to comment https://forums.phpfreaks.com/topic/84592-solved-strip-a-0-from-a-mobile-number-and-add-44-instead/#findComment-431058 Share on other sites More sharing options...
neylitalo Posted January 5, 2008 Share Posted January 5, 2008 What happens if there's a 0 in the middle of the number? You'd get 44's throughout the number, in places that you don't want them to be. To take care of this problem, something like this will do the trick nicely: <?php $mobile_number = "07832128604"; $mobile = preg_replace("/^0(.*)/", "44\\1", $mobile_number); print $mobile; ?> Quote Link to comment https://forums.phpfreaks.com/topic/84592-solved-strip-a-0-from-a-mobile-number-and-add-44-instead/#findComment-431059 Share on other sites More sharing options...
cr-ispinternet Posted January 5, 2008 Author Share Posted January 5, 2008 Ahhhhh! * says nothing * thanks for the pointer :-) Alan Quote Link to comment https://forums.phpfreaks.com/topic/84592-solved-strip-a-0-from-a-mobile-number-and-add-44-instead/#findComment-431063 Share on other sites More sharing options...
cr-ispinternet Posted January 5, 2008 Author Share Posted January 5, 2008 As you said :-) this was from my log, my own mobile number has a 0 further down can you do me a favour and explain exactly what u have done addding the extra bits in i really appreciate the help with that i think its saved my platform :-) had to many sms messages nto getting delivered and this is the only thing i can think of :-) Alan <-------------- New Campaign Check Start [2008-01-05 09:07] Send Sms Delayed -------------> [2008-01-05 09:07] QUERY: SELECT * from sms_delayed_campaigns where approved='Y' and processed='N' and processing='0' and sms_type='delayed' LIMIT$ [2008-01-05 09:07] DATE AND TIME: Sending Date and Time is 2008-01-05 & 08:10 [2008-01-05 09:07] CURRENT TIME AND DATE: Current time is 09:07 and current date is 2008-01-05 [2008-01-05 09:07] QUERY: SELECT * from sms_delayed_campaigns where '2008-01-05' <= '2008-01-05' and '08:10' <= '09:07' and approved= 'Y' and proc$ [2008-01-05 09:07] PROCESSING: Updating Campaigns Database Processing=1 --> Sending to 4477253447138 SESSION ID: 9057780a67dd955d725d5dfe92df890a [2008-01-05 09:07] SUCCESS ID: e151190c557c6e3f59c6438aab4cb5b0[2008-01-05 09:07] PROCESSING: Updating Campaigns Database Processing=0 [2008-01-05 09:07] PROCESSING SMS: Updated Processing field to Y in sms_delayed_campaigns [2008-01-05 09:07] FROM: Smooth [2008-01-05 09:07] TITLE: testing instant logs [2008-01-05 09:07] MESSAGE: some message here! [2008-01-05 09:07] QUERY: SELECT * FROM members WHERE mobile_number LIKE '07725307138' AND member_status= 'Full' <-------------- New Campaign Check Finish [2008-01-05 09:07] Send Sms Delayed -------------> Quote Link to comment https://forums.phpfreaks.com/topic/84592-solved-strip-a-0-from-a-mobile-number-and-add-44-instead/#findComment-431064 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.