#1
  1. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,003
    Rep Power
    376

    Outputting file content, it has spaces?


    Ok i have a file of email addresses.

    When i do this:

    PHP Code:
     $handle = @fopen($original_file"r");
        
        
    $count =0;
        if ( 
    $handle) {
            while ((
    $buffer fgets($handle)) !== false) {
                
    print_r($buffer); 
    buffer has: e m a i l a d d r e s s.. instead of emailaddress?

    btw i am echoing onto CLI if that makes a difference?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,508
    Rep Power
    594
    The function print_r is for debugging purposes. It is not for formatting output.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Iran
    Posts
    149
    Rep Power
    139
    Can we have a sample of the file?
    Regards,
    Dariyoosh
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Iran
    Posts
    149
    Rep Power
    139
    Originally Posted by gw1500se
    The function print_r is for debugging purposes. It is not for formatting output.
    It is true that as you said, print_r() is not to be used for that, however I don't think that this is what causes the problem, because if the type of the parameter passed to print_r() is string, then according to the manual, the value is returned

    www.php.net/manual/en/function.print-r.php
    If given a string, integer or float, the value itself will be printed. If given an array, values will be presented in a format that shows keys and elements. Similar notation is used for objects.
    Regards,
    Dariyoosh
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,003
    Rep Power
    376
    thanks guys.

    I also after doing some processing ECHO the buffer instead of printing and it still returns e m a i l a d..

    If i do it from a web browser then i get the right output?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,508
    Rep Power
    594
    Post the code you are now using to format the output.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo