Jump to content


Photo

how to split dash in php?


  • Please log in to reply
3 replies to this topic

#1 lilywong

lilywong
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 23 March 2006 - 09:13 AM

i have a list of phone number key in with 012-34567897
i want to split the '-' so that the phone number become 01234567897.

anyone knows how to do that ? thanks

#2 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 23 March 2006 - 09:17 AM

[!--quoteo(post=357525:date=Mar 23 2006, 09:13 AM:name=rach)--][div class=\'quotetop\']QUOTE(rach @ Mar 23 2006, 09:13 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
i have a list of phone number key in with 012-34567897
i want to split the '-' so that the phone number become 01234567897.

anyone knows how to do that ? thanks
[/quote]

i guess this would do you:

$num = str_replace('-', '', $num);

hope that helps
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#3 lilywong

lilywong
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 23 March 2006 - 09:23 AM

anyway we can do that using sql command ?

#4 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 23 March 2006 - 09:46 AM

[!--quoteo(post=357528:date=Mar 23 2006, 09:23 AM:name=rach)--][div class=\'quotetop\']QUOTE(rach @ Mar 23 2006, 09:23 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
anyway we can do that using sql command ?
[/quote]

you'd have to check, but something like:

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] REPLACE(Telnum, '[span style=\'color:orange\']-'[/span], '') as NiceTelnum FROM mytable [!--sql2--][/div][!--sql3--]

may work for you
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users