Results 1 to 8 of 8
  1. #1
    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?

  2. #2
    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. #3
    Join Date
    May 2002
    Posts
    604
    No the string is "hello".

    echo $var.".";

    did not solve the problem :\

  4. #4
    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. #5
    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. #6
    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. #7
    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. #8
    Join Date
    May 2002
    Posts
    604
    Don't worry I solved it...

Related Posts from theWHIR.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •