Inconsistent php sematics witrh trim() ... or can't trim() handle assignment with same variable?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just ran into this annoying thing today:


Why does this /NOT/ work to remove NL's:

    $AccNr = fgets($fp);
    while ( !feof($fp) ) {

       $AccNr = trim($AccNr);  /// trim() DOES NOT WORK HERE
       $InsertStr = "insert into $UpLoadTable values ('$AccNr')";
       print "<pre>$i: Inserting: $InsertStr </pre>";
       ob_flush();
       mssql_query($InsertStr);

       $AccNr = fgets($fp);
    }

while this works just fine to remove NL's:

    $AccNR = trim( fgets($fp) );  // trim WORKS JUST FINE HERE
    while ( !feof($fp) ) {

       $InsertStr = "insert into $UpLoadTable values ('$AccNr')";
       print "<pre>$i: Inserting: $InsertStr </pre>";
       ob_flush();
       mssql_query($InsertStr);

       $AccNr = trim( fgets($fp) ); // trim WORKS JUST FINE HERE

    }

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux