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 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; 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... 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 Link to comment https://forums.phpfreaks.com/topic/125844-subsrt-help/#findComment-650735 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.