Jump to content

Extra characters after a "while" loop


TobesC

Recommended Posts

thanks - that solved the problem, but only for half of the links (?). heres the other set that im creating. same problem, extra character after the word. i included the "trim" also.

 

<?php

$file = fopen($p.".txt", "r");

while(!feof($file)) {

    $j=$j+1; ?>

    <?php if ($a!=$j) { ?><a href="index.php?p=<?php echo $p; ?>&a=<?php echo $j; ?>&r=<?php echo $r; ?>"><?php } ?><?php echo trim(fgets($file)); ?> <?php if ($a!=$j) { ?></a><?php } ?> |

<?php

}

?>

There is probably some other hidden character that trim() doesn't deal with.  Try this diagnostic script:

 

<?php
$file = fopen($p.".txt", "r");
$j = 0;
while(!feof($file)) {
    $j++;
    print "Line $j: " . urlencode(fgets($file)) . "<br>";
}
?>

 

What that will do is it will show you the ascii values of any invisible characters.  After running this, post an extract of the output (or full output if it's small) and we can see what needs doing.  For this script, don't use trim().

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.