Gem Hexen
08-29-2002, 03:33 AM
Ok I get a random variable from an array ( a text file) and assign it to $var
then I say
echo "$var.";
However, the output is:
hello . (extra space after the variable :/)
HOW can I remove that space?
Studio64
08-29-2002, 03:40 AM
echo $var.".";
That should do it.. :D
Although... On second thought the extra " " could actually be included in the $var string itself... Instead of what you believe could be "hello" could actually be "hello "...
Gem Hexen
08-29-2002, 03:43 AM
No the string is "hello".
echo $var.".";
did not solve the problem :\
Gem Hexen
08-29-2002, 03:46 AM
ok it has something to do with reading it from a file. It only has an extra space if its out of the file
so my question now is:
how do I remove the last character from a string?
Studio64
08-29-2002, 03:48 AM
$var = trim($var);
trim(string str)
This function strips whitespace from the start and the end of a string and returns the stripped string. The whitespace characters it currently strips are: "\n", "\r", "\t", "\v", "\0", and a plain space
Gem Hexen
08-29-2002, 03:55 AM
Hey since you're really on a roll, is there a way to display the text output from a php script on another server that doesn't have php? Or have the php script output the text in a way that it can be included on a page on this other server as text?
Studio64
08-29-2002, 04:06 AM
$filename = "output.txt";
$handle = fopen($filename, 'a+');
fputs($handle, $text_to_be_written);
fclose($handle);
Make sure the file has writeable attributes....
If you want a new line after each item included
$text_to_be_written."/n"=$text_to_be_written
Glad to help ya out but, it's about 3am now...
I have about 13 beers tonight and I have class in the morning...
Hope I've been of some assitance...
err... I missed the other computer part...
Umm.. You could map a drive or alias to the other drive to the other computer to write to....
I have no clue if my last comment makes sense now. I'll figure it out during REM sleep.....
Gem Hexen
08-29-2002, 04:38 AM
Don't worry I solved it...