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

}

?>

Link to comment
Share on other sites

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().

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.