GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Program to create files based on a text list? (https://gfy.com/showthread.php?t=728957)

uno 04-30-2007 11:16 AM

Program to create files based on a text list?
 
Does anyone know of a program to create files based on a text list?

For ex. my text list would look like:

1
2
3
4
5

I'd want to create:
1.txt
2.txt
3.txt
4.txt
5.txt

etc...

SmokeyTheBear 04-30-2007 11:22 AM

would be simple to do in php

what would you like the file to contain.?

uno 04-30-2007 11:30 AM

Quote:

Originally Posted by SmokeyTheBear (Post 12335736)
would be simple to do in php

what would you like the file to contain.?

some code that would also contain the name of the file-ext. in the file.

SmokeyTheBear 04-30-2007 11:36 AM

Quote:

Originally Posted by uno (Post 12335785)
some code that would also contain the name of the file-ext. in the file.

ok well heres how you do it in php

make a folder somewhere

put the code below in a file called index.php

make a folder called results. this is where the created files willl be saved ( chmod the folder to be writeable )

save the list in a file called file.txt ( in the same folder as index.php )

Code:

<?php

$fil = "file.txt";
$sc = file_get_contents($fil);
$emt = explode("\n",$sc);

  foreach( $emt as $pn => $mub){

$dub = str_replace(" ","-",$mub);
$wrt = "STUFF INSIDE FILE $dub.txt";
$fol = "results/$dub.txt";
echo "Saved $dub.txt \n<br>";
$hn = fopen($fol, 'w+');
fwrite($hn, $wrt);
fclose($hn);
}
?>


SmokeyTheBear 04-30-2007 11:53 AM

if you have troubles let me know

uno 04-30-2007 01:20 PM

Wow, thanks man!

uno 04-30-2007 01:49 PM

I'm really going to need to learn php one of these days.


All times are GMT -7. The time now is 12:01 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123