php - Stuck with file_get_contents
guys. Please help me to find out the problem. I have one script on my ftvgirlsbay.com site:
<?php
define('C', 16); // NUMBER OF ROWS
define('D', 6); // NUMBER OF CELLS
$file = @file_get_contents('http://ftvgirlsbay.com/design/tables/gals.txt');
if($file === FALSE) {
echo "<h2>Make file gals.txt with data!</h2>";
return FALSE;
}
$file = explode("\r\n", $file);
$thumbs = array();
while(list(,$el) = each($file)) {
$el = explode('|', $el);
if(isset($el[0]) && isset($el[1]))
$thumbs[] = array($el[0], $el[1]);
}
//print_r($thumbs);
$size = sizeof($thumbs);
if($size < C*D) {
echo "<h2>More data needed. You have $size, you need ".C*D."!</h2>";
return FALSE;
}
$range = range(0, $size - 1);
shuffle($range);
//print_r($range);
?>
<table align=center>
<?php
$num = 0;
for($i = 0; $i < C; $i++) {
echo '<tr align=center>'."\r\n";
for($k = 0; $k < D; $k++) {
echo '<td><a href="'.$thumbs[$range[$num]][1].'">FTV '.$thumbs[$range[$num]][0].' Gallery</a> </td>'."\r\n";
$num++;
}
echo '</tr>'."\r\n";
}
?>
</table>
Result of this script: "More data needed. You have 1, you need 96!" ( http://ftvgirlsbay.com/random_scripts/test.php )
If this part
$file = @file_get_contents('http://ftvgirlsbay.com/design/tables/gals.txt');
change to
$file = @file_get_contents('http://sexsticker.info/ftvgirlsbay.com/pictable/gals.txt');
it works just fine
( http://ftvgirlsbay.com/random_scripts/test2.php )
So if I links to the .txt file on my server's side script reads only 1 line. If I links to the .txt on the remote server - script works wilh all lines
Answer
Solution:
I figured out your problem and was able to replicate the issue.
The issue is with the
\r
inRemove the
\r
Both servers might be different. One may be on a Linux, while the other on a Windows server.