Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fwrite issue

Status
Not open for further replies.

dagoat10

Programmer
Jun 3, 2010
74
US
i have been trying to write to a file, but i get indentation in the file. I can get rid of the ^M characters but it's all shifted and each entry is a line, rathar then each row is a line.

example:
1
Name
Team
State
Code:
<?php

$file = file("[URL unfurl="true"]http://www.nfl.com/stats/categorystats?tabSeq=1&statisticPositionCategory=QUARTER[/URL]
//$file = file("[URL unfurl="true"]http://charon.cs.wau.edu/~pkioko/Fantasy_Football.html");[/URL]
//$file = file("[URL unfurl="true"]http://sports.yahoo.com/nfl/stats/byposition?pos=QB");[/URL]
$player_count = 1;

$newfile = "QB.txt";
$handle = fopen($newfile, 'w');

foreach ($file as $file_line => $files)
{
    $files = strip_tags($files);
    $chars = htmlspecialchars($files);
    $chars = strval($chars);
    $chars2 = explode(",", $chars);
    $chars3 = $chars2[0] . $chars2[1];
    if($file_line >= 1459 && $file_line <=11179 && $file !== " ")
    {
        //echo "Line #<b>{$file_line}</b> : " . htmlspecialchars($files) . "<br />\n";
    
        if($chars3 == $player_count)
        {
            //echo "<br>\n";
            $player_count++;
        }
   
        echo  htmlspecialchars($files);
        //fwrite($handle, $chars4);
    }



}
fclose($handle);
?>
 
hopefully I have answered your question in your other post.

you take the data that my code outputs and do this

Code:
$fH = fopen('QB.txt', 'wb');
foreach ($results as $result):
   fput_csv($fH, $result, ',', '"');
endforeach;
 
it's nice, but still does not work all it gives me back is
Array ()

i can't upgrade because i don't have permission to, so i am stuck with PHP 4.1.2, so file_get_contents does not work.
 
i don't get any rows returned and i have to use file() because i am under PHP 4.1.2
 
i have provided you with a curl alternative.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top