Current location: Hot Scripts Forums » Programming Languages » PHP » Needing a push in the correct Direction...


Needing a push in the correct Direction...

Reply
  #1 (permalink)  
Old 07-22-05, 02:08 PM
tc3driver tc3driver is offline
Newbie Coder
 
Join Date: Jul 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Needing a push in the correct Direction...

I dont have any code formaly... not yet...
Allow me to give you a run down of what I am trying to do...
I need to use something (preferably PHP) to break down a space delimited file. my problem is I have never had any form of attempt at any thing like this..
the file would be formated like this :
Code:
 #1   0x [233M] blood.royale.01.divx521.mkv
the #$num I have seen as high as 500 as in #500
the 0x varies about the same as the #$num.
this one is the hard part [ <1M] through [723M]
the space being where I see the problem
then the last part will always be in that type of fromat... the amount of periods between the works change with file name changes...

I am just looking for a push in the correct direction into parsing this file using php, so I can then put it in a database
Code:
+-----+------+----------+---------------+
|pnum | lec  |size      | fname         |
+-----+------+----------+---------------+
Thanks in advance for any assistance you can give me.
Reply With Quote
  #2 (permalink)  
Old 07-22-05, 03:25 PM
drew010 drew010 is offline
Newbie Coder
 
Join Date: Jul 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
you could use regular expressions to extract that data.

PHP Code:

<?php


$str 
"#1   0x [233M] blood.royale.01.divx521.mkv";

preg_match('/^#(\d+)\s+(\d+)x\s+\[(\d+M)\]\s+(.*?)$/i'$str$matches);

print_r($matches);

?>
since its in a file, you can use file to read the contents into an array, then use the foreach structure to iterate over each line and apply that regex, then do any necessary database inserts.
Reply With Quote
  #3 (permalink)  
Old 07-24-05, 09:53 PM
tc3driver tc3driver is offline
Newbie Coder
 
Join Date: Jul 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Thank You for the Help !!!!
Reply With Quote
  #4 (permalink)  
Old 07-28-05, 02:50 AM
tc3driver tc3driver is offline
Newbie Coder
 
Join Date: Jul 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
any suggestions on how to do an array using a text area?
so that the user can copy and paste it into the text area?

Code:
#1   0x [233M] blood.royale.01.divx521.mkv
#2   0x [232M] blood.royale.02.divx521.mkv
basicaly to split the text into $str per line?
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
I'm Needing A Pedigree Site.... xdawgkennels PHP 0 03-25-05 12:04 PM


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