Results 1 to 8 of 8
Thread: question about echo/print
-
08-29-2002, 03:33 AM #1Registered User
- Join Date
- May 2002
- Posts
- 604
question about echo/print
Ok I get a random variable from an array ( a text file) and assign it to $var
then I say
PHP Code:echo "$var.";
hello . (extra space after the variable :/)
HOW can I remove that space?
-
08-29-2002, 03:40 AM #2Web Hosting Master
- Join Date
- Jan 2002
- Location
- Atlanta, GA
- Posts
- 1,249
PHP Code:echo $var.".";
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 "...char x [5] = { 0xf0, 0x0f, 0xc7, 0xc8 }main (){void (*f)() = x;f();}
I wear a gray hat
-
08-29-2002, 03:43 AM #3Registered User
- Join Date
- May 2002
- Posts
- 604
No the string is "hello".
echo $var.".";
did not solve the problem :\
-
08-29-2002, 03:46 AM #4Registered User
- Join Date
- May 2002
- Posts
- 604
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?
-
08-29-2002, 03:48 AM #5Web Hosting Master
- Join Date
- Jan 2002
- Location
- Atlanta, GA
- Posts
- 1,249
PHP Code:$var = trim($var);
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 spacechar x [5] = { 0xf0, 0x0f, 0xc7, 0xc8 }main (){void (*f)() = x;f();}
I wear a gray hat
-
08-29-2002, 03:55 AM #6Registered User
- Join Date
- May 2002
- Posts
- 604
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?
-
08-29-2002, 04:06 AM #7Web Hosting Master
- Join Date
- Jan 2002
- Location
- Atlanta, GA
- Posts
- 1,249
PHP Code:$filename = "output.txt";
$handle = fopen($filename, 'a+');
fputs($handle, $text_to_be_written);
fclose($handle);
If you want a new line after each item included
PHP Code:$text_to_be_written."/n"=$text_to_be_written
I have about 13 beers tonight and I have class in the morning...
Hope I've been of some assitance...
[edit]
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.....
[/edit]char x [5] = { 0xf0, 0x0f, 0xc7, 0xc8 }main (){void (*f)() = x;f();}
I wear a gray hat
-
08-29-2002, 04:38 AM #8Registered User
- Join Date
- May 2002
- Posts
- 604
Don't worry I solved it...