You are here: How can I preserve leading white space? « PHP Language « IT news, forums, messages
How can I preserve leading white space?

Posted by Dave on 11/22/05 06:52

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>";
?>





--
Dave K

http://www.southminster-branch-line.org.uk/

Please note my email address changes periodically to avoid spam.
It is always of the form: month-year@domain. Hitting reply will work
for a couple of months only. Later set it manually. The month is
always written in 3 letters (e.g. Jan, not January etc)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация