English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I can write a string to the screen, but if i want to put tabs between them, php will print ONLY ONE space instead of the tab. if i replace the '\t' with 50 spaces, the screen will only output one. im trying to create a tree like structure like the following


element one
** response to element one
element two
** response to element two


each of the tabs is reduced to one character. can anyone help??

2007-07-06 08:39:35 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

Extra whitespace (beyond a single space) is ignored in HTML. You'll either have to use non-breaking spaces (an HTML Entity) or use the CSS text-indent property.

2007-07-06 08:43:22 · answer #1 · answered by Chad 5 · 0 0

Try formatting your page in HTML. Unless you get PHP to print to a text file, your page will show up as HTML where excess spacing is usually ignored.

At the very least, putting a

 in front of anything you output and a 
after it will preserve any spacings you have

2007-07-06 15:44:31 · answer #2 · answered by jonathanlks 4 · 0 0

extra white spaces will always be counted as one. To include more than 1 white space use the non blank space entity of HTML. Just put   where ever you want an extra space any number of times

2007-07-06 15:46:09 · answer #3 · answered by CrazyCoder 3 · 0 0

Here's PHP code to do just what you show:
print '

'
print 'element one\n'
print ' \t '
print 'response to element one\n'
print 'element two\n'
print ' \t '
print 'response to element two\n'
print '
'
?>

The other method might be to create an HTML textarea control and include the spaces and tabs in that (although I've never tried putting tabs in a textarea before).
print ''
?>

2007-07-06 15:49:58 · answer #4 · answered by Chris C 7 · 0 0

fedest.com, questions and answers