hi guys, id like to ask how can i do this:
1. the text file should be uploaded by the user (is there any codes you can provide)
2. i have a text files that is not comma-delimited, only fixed width. though basically i just need 2 - 3 fields to be imported to the database. (the reason why i need this because of the nature of legacy database we're using... btrieve, that's why i just rely to text files being generated)
here's the sample data:
XXXXX 1004567 I09890990 DELACRUZ, JUAN 01/09/06
XXXXX 1004568 I09890990 DELACRUZ, JUAN 01/09/06
XXXXX 1004569 I09890990 DELACRUZ, JUAN 01/09/06
XXXXX 1004575 I09890990 DELACRUZ, JUAN 01/09/06
assuming that i need the records for the second & third column? how can i get those?
i hope you could help me... thanks!
help in my fixed-width text file & php
Moderator: General Moderators
-
mfmondragon
- Forum Newbie
- Posts: 4
- Joined: Sat Jan 27, 2007 12:17 am
http://de3.php.net/manual/en/function.sscanf.php might be helpful.
-
mfmondragon
- Forum Newbie
- Posts: 4
- Joined: Sat Jan 27, 2007 12:17 am
-
mfmondragon
- Forum Newbie
- Posts: 4
- Joined: Sat Jan 27, 2007 12:17 am
feyd | Please use
thanks again!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
oops, i got it working now... thanks! but i just need to third row. how can i get and pass it into a variable?
here's my code...Code: Select all
<?php
$fp = @fopen("studlst.txt", "rb") or die("Couldn't open file");
$data = fread($fp, filesize($fp));
while(!feof($fp))
{
$data .= fgets($fp);
}
fclose($fp);
$values = explode("\r\n", $data);
foreach ($values as $val)
{
$read = sscanf($val,"%24s %s %d");
print_r ($read);
echo ("<br />");
}
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]