Reading File in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rizmughal
    New Member
    • Sep 2006
    • 1

    #1

    Reading File in php

    Dear Experts,

    i am opeing a text file in php, when i print file contents using the given bellow script it excludes the spaces

    Example

    in Text file:
    123______456___ ____789 "_" is equal to space

    but when i print this like using file_get_conten ts it print like
    123 456 789

    i want same line with spaces

    Thanks in advance

    $filestring = file_get_conten ts($newpath);
    $filearray = explode("\n", $filestring);
    while (list($line_no, $line) = each($filearray ))
    {
    print "Line $line_no: $line<BR />";
    }
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    The browser only prints one blank within a series of blanks. You must replace each blank by a &nbsp; So replace your print line by:
    [PHP]print "Line $line_no: ".str_repla ce(" ", "&nbsp;", $line)."<BR />";
    [/PHP]

    Ronald :cool:

    Comment

    Working...