|
Posted by Tyrone Slothrop on 11/22/05 07:17
On Tue, 22 Nov 2005 04:52:55 +0000, Dave
<INVALID.See-signature-for-how-to-determine@southminister-branch-line.org.uk>
wrote:
>This simple example:
>
><?php
>$str=" now, after all the spaces some text";
>echo $str;
>?>
>
>prints:
>
>now, after all the spaces some text
>
>
>However, I want to preserve white space, so it prints the leading spaces.
>
> now, after all the spaces some text
>
>Can anyone suggest how to do it?
>
>My actual program (rather than that simple example) prints stdout from
>an executable program after the output is opened with popen, read with
>fgets and printed with echo - see below. But I think the problem is the
>same as in the above simpler code.
>
><?php
>
>$cmd=$_POST['input_data']; // Read from a form.
>
>$handle = popen("echo $cmd | /usr/local/bin/math" , "r");
>$data=fgets($handle);
>echo "$data<br>";
>?>
How do you know the spaces are not still there? In HTML you will see
only one space, no matter how many spaces may be in the source.
Do a str_replace (" ", " ", $data);
[Back to original message]
|