calling line from text file, won't display past & ampersand?
Posted: Mon Jul 12, 2010 11:19 am
Hey Guys,
So I have this code, it takes a line from a text file and uses that line as part of a post that it is scheduled to make via cron job to a website.
The code is ALMOST doing it's job - except for one thing - if the line contains an ampersand "&" then the line 'ends' there when brought back to the code.
ie:
http://www.billybobssite.com/user/profile=jmike&19428
becomes
http://www.billybobssite.com/user/profile=jmike
stripping the
&19428
Two things:
1. Why is it doing this?
2. How do I fix it?
=)
So I have this code, it takes a line from a text file and uses that line as part of a post that it is scheduled to make via cron job to a website.
The code is ALMOST doing it's job - except for one thing - if the line contains an ampersand "&" then the line 'ends' there when brought back to the code.
ie:
http://www.billybobssite.com/user/profile=jmike&19428
becomes
http://www.billybobssite.com/user/profile=jmike
stripping the
&19428
Two things:
1. Why is it doing this?
2. How do I fix it?
=)
Code: Select all
function NextLine() {
$textfile = "links.txt";
if(file_exists($textfile)){
$sites = file($textfile, FILE_SKIP_EMPTY_LINES);
if(!empty($sites)) {
$string = array_shift($sites);
file_put_contents($textfile, implode($sites));
} else {
$string = "Empty";
}
} else {
$string = "Error";
};
return $string;
}
$s0 = NextLine();
echo "$s0";