Current location: Hot Scripts Forums » Programming Languages » PHP » need a bit of help with a script


need a bit of help with a script

Reply
  #1 (permalink)  
Old 06-27-09, 01:12 PM
kevinkhan kevinkhan is offline
Newbie Coder
 
Join Date: Jun 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
need a bit of help with a script

Hi guys,

I have a script that extracts numbers from a .txt file.. but it list the numbers in these formats

087-9850714
(087) 9850714
(087)9850714
087 9850714
0879850714

Is there anyway of changing these numbers and putting them all in this format

0879850714
0879850714
0879850714
0879850714
0879850714
Reply With Quote
  #2 (permalink)  
Old 06-27-09, 02:02 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Try this, it'll strip out everything but the numbers:

$data = preg_replace("/[^0-9]/",'', $data);
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
  #3 (permalink)  
Old 06-27-09, 02:04 PM
kevinkhan kevinkhan is offline
Newbie Coder
 
Join Date: Jun 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
ok thanks

Im not too familier with php

could you tell me what lines to put this on please?
Reply With Quote
  #4 (permalink)  
Old 06-27-09, 08:55 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Try sed

sed "s/[^0-9]//" file.txt > newfile.txt

You might also want to use sort, then uniq - like so:

sort newfile.txt|uniq
Reply With Quote
  #5 (permalink)  
Old 06-28-09, 04:20 AM
kevinkhan kevinkhan is offline
Newbie Coder
 
Join Date: Jun 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Ok thanks for your reply

but im totally lost..

Where abouts do i put this code.. inside the loop?
or do i remove the php code that is already in it?
Reply With Quote
  #6 (permalink)  
Old 06-28-09, 07:15 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Excuse me kevinkhan, but did you ever stop to think that we haven't seen your code
and you are asking us to tell you something as if we know your code?

Maybe if you would stop and think a little, you might realize that we can't answer your question unless you show us your code.
__________________
Jerry Broughton
Reply With Quote
  #7 (permalink)  
Old 06-28-09, 01:03 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
Put it on line 13.
Reply With Quote
  #8 (permalink)  
Old 06-28-09, 10:17 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Please show us the relevant code and we will be more than happy to help you.
__________________
Jerry Broughton
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gallery script good/bad idea? joshg678 PHP 2 12-22-08 08:41 AM
Login Script v1.9 Problem SuavyDoodle JavaScript 8 09-28-06 09:13 PM
Help me with this script !!! phpfreek Job Offers & Assistance 0 04-12-06 05:19 PM
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 12:12 AM


All times are GMT -5. The time now is 08:40 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.