Hello everyone. I am trying to learn PHP and I am stuck.
I have a text file that has the numbers 1 through 9, each listed on its own line. I want to read each line of the file, and write it to a new text file UNLESS one of the numbers is passed through the URL.
So for example, if the url variable is 8, then it will read the first file and write
1
2
3
4
5
6
7
9
To the second file.
Here is what I got:
<?php
$linknum = $_GET['linknum'];
//----This works if $xx = 8;
//$xx = 8;
//----but it does not work if $xx = $linknum;
$xx = $linknum;
$data = file ("Source_file.txt");
$b = fopen("New_File.txt", "w+");
foreach ($data as $zz) {
if ($zz != $xx){
fwrite($b, $zz);
}
}
?>
Please help me!