|
Zante Zapedzki
We need html on a prim!
Join date: 15 Feb 2007
Posts: 123
|
11-10-2007 04:23
I'm trying to create an "Event displayer" and have just about everything sorted with the exception of one small problem. I'm not an expert with PHP or LSL and I've had to do some learning but so far I have a web form that, when altered, will create a txt file from which a PHP script reads the contents. When I use xytext to display the strings (via llhttprequest), I have the pi symbol appearing at the end of every line. Is this a carriage return and does anyone know who to get rid of it? If you see the attachment you'll understand the problem. In php, each line is stored as a value within an array. Could this be causing problems? The php looks like this... <?php $file = fopen("events.txt", "r"  or exit("Unable to open file!"  ; $count = 0; while(!feof($file)) { $count++; $event_array[$count] = fgets($file); } echo $event_array[1]; echo $event_array[2]; echo $event_array[3]; echo $event_array[4]; fclose($file); ?> Any ideas?
|
|
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
|
11-10-2007 06:25
This might indeed be the CR at the end of the line. Try to alter your reading routine like this: while(!feof($file)) { $count++; $event_array[$count] = trim(fgets($file));
}
the trim command deletes spaces (and thus, CR's) from the beginning and the end of a string. Btw: if you just fill up an array, you don't have to add a key. you could simply write: $event_array[] = trim(fgets($file));
you'll end up with the same result as numerical keys are added automatically to the array... HTH
|
|
Zante Zapedzki
We need html on a prim!
Join date: 15 Feb 2007
Posts: 123
|
11-10-2007 06:38
Oh, thank you so much! : D
|
|
Patrick2 Chama
Registered User
Join date: 15 Sep 2006
Posts: 52
|
11-10-2007 09:16
Here, cleaner version, should be faster too.
<?php $lines = file('events.txt'); foreach($lines as $line) { $line = trim($line); // if($line == ''){continue;} // Uncomment if you want to skip blank lines print $line; } ?>
|