hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : question about echo/print
Reply

Forum Jump

question about echo/print

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 08-29-2002, 03:33 AM
Gem Hexen Gem Hexen is offline
Registered 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."
However, the output is:

hello . (extra space after the variable :/)

HOW can I remove that space?



Sponsored Links
  #2  
Old 08-29-2002, 03:40 AM
Studio64 Studio64 is offline
Web Hosting Master
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 1,249
PHP Code:
echo $var."."
That should do it..

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

  #3  
Old 08-29-2002, 03:43 AM
Gem Hexen Gem Hexen is offline
Registered User
 
Join Date: May 2002
Posts: 604
No the string is "hello".

echo $var.".";

did not solve the problem :\

Sponsored Links
  #4  
Old 08-29-2002, 03:46 AM
Gem Hexen Gem Hexen is offline
Registered 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?

  #5  
Old 08-29-2002, 03:48 AM
Studio64 Studio64 is offline
Web Hosting Master
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 1,249
PHP Code:
$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

__________________
char x [5] = { 0xf0, 0x0f, 0xc7, 0xc8 }main (){void (*f)() = x;f();}
I wear a gray hat

  #6  
Old 08-29-2002, 03:55 AM
Gem Hexen Gem Hexen is offline
Registered 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?

  #7  
Old 08-29-2002, 04:06 AM
Studio64 Studio64 is offline
Web 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); 
Make sure the file has writeable attributes....

If you want a new line after each item included
PHP Code:
$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...

[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

  #8  
Old 08-29-2002, 04:38 AM
Gem Hexen Gem Hexen is offline
Registered User
 
Join Date: May 2002
Posts: 604
Don't worry I solved it...

Reply

Related posts from TheWhir.com
Title Type Date Posted
Emerging Tech: Email, Security and Privacy Blog 2013-08-29 11:29:43
UK Tech Blog Challenges CloudFlare, Web Hosts on Free Speech Blog 2013-08-12 10:32:52
The Value of Your Intellectual Property Blog 2013-05-06 17:43:13
Joomla Hosting Study Shows Speed, Uptime Top Selling Points of a Web Host Web Hosting News 2012-11-07 15:06:36
10-14-2012 Roswell, NM - The Hosting Shift Blog 2012-10-24 15:14:40


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?