confused_aswell Posted September 25, 2008 Share Posted September 25, 2008 Hi I need to put a space in a phone number that is being returned from the database. I have read to use the substr() function but don't really know how to get going. If the phone number is 01234567890 then I will need to put a space after the 5th number, but if the number is 01234 567890 then I don't need to do anything to it. Can someone help with some code please? Thanks, Phil Quote Link to comment https://forums.phpfreaks.com/topic/125844-subsrt-help/ Share on other sites More sharing options...
sKunKbad Posted September 25, 2008 Share Posted September 25, 2008 $first = substr("01234567890", 0,5); // returns "01234" $last = substr("01234567890", -6); // returns "567890" echo $first . " " . $last; Quote Link to comment https://forums.phpfreaks.com/topic/125844-subsrt-help/#findComment-650731 Share on other sites More sharing options...
DarkWater Posted September 25, 2008 Share Posted September 25, 2008 You already posted this, and someone already gave a solution... Quote Link to comment https://forums.phpfreaks.com/topic/125844-subsrt-help/#findComment-650732 Share on other sites More sharing options...
confused_aswell Posted September 25, 2008 Author Share Posted September 25, 2008 Hi Thanks very much I will try it later. Phil Quote Link to comment https://forums.phpfreaks.com/topic/125844-subsrt-help/#findComment-650735 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.