Re: please help me I try to post my question to Php.net 2-3 times
| From: | Kim Christensen | Date: | Thu, 16 Feb 2006 12:07:00 +0000 |
| Subject: | Re: please help me I try to post my question to Php.net 2-3 times | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-230530@lists.php.net to get a copy of this message | ||
On 2/16/06, wvolks@ego.co.th <wvolks@ego.co.th> wrote:
> $filename =3D "c:data.txt";
> $contents =3D file($filename);
> echo $contents;
> ?>
> // data in text file is "1_____2_____3_____4" < _ =3D blank>
> // output is "1 2 3 4"
> // I want fixed possition . please help me ?
I'm not really sure what you're trying to do, but I assume you want to
keep the four(?) spaces when you output the data. If you're going to
display it using HTML, you have to replace the spaces with -
otherwise HTML truncates the excess whitespace. Try using REGEX:
$contents =3D file($filename);
echo preg_replace("/\s/", " ", $contents);
This regular expression will replace all whitespace
(spaces/newlines/carriage returns) with the character , which in
HTML yields a blank space.
--
Kim Christensen
kim.christensen@gmail.com