[SOLVED]What's wrong?
Posted: Sat Oct 16, 2010 2:01 pm
Can anyone tell me what's wrong with my code?
What I'm trying to do is make a PHP file that will take a parameter like : http://www.mysite.com/log.php?IDs=1,2,3 and then add to the ID.txt "1\n2\n3\n" (the \n meaning new line).
Solved
Code: Select all
<?php
$IDs = preg_split("/[\s]*[,][\s]*/", $_REQUEST['IDs']);
$myFile = "IDs.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
for ( $counter = 0; $counter < count($IDs); ++$counter)
{
fwrite($fh, $IDs[counter]."\n");
echo $IDs[counter]."\n";
}
fclose($fh);
?>Solved