Page 1 of 1

displaying white spaces in table cell

Posted: Wed Nov 19, 2003 6:52 am
by yaron
hello all,
is there a way (using php or html) to force the browser to display white spaces at begining of a string inside a table cell?
i.e. if I have a string: " hello"

and I put it into a cell it prints out
"hello"
and I want to see is
" hello"
within the cell...
possible?

Posted: Wed Nov 19, 2003 7:32 am
by Nay
Maybe a:

Code: Select all

<?php
$text = str_replace(" ", "\&\n\b\s\p\;", $text);
?>
But then, using that, it would replace all the spaces, I doubt you'd want that, and it'd end up as <table\&\n\b\s\p\;cellpadding="0" etc.

But I might go along that str_replace line. Maybe use regular expressions to look for a <td> text</td> pattern?

-Nay

ps: I added the ''s since when you read the post, the entities kept changing into spaces.

Posted: Wed Nov 19, 2003 7:36 am
by twigletmac
Are you doing this in order to pad the cell? Or for another reason?

Mac

Posted: Wed Nov 19, 2003 7:37 am
by igoy
no ... i don't think it's supported... white spaces before text in table cells..

either use

Code: Select all

<table cellpading="10">
  <tr>
    <td><?php echo $string ?></td>
  </tr>
</table>
or else........

Code: Select all

<td>&\nbsp;<?php echo $string ?></td>
note : remove that "\" from "&\nbsp;" before using in code..

Posted: Wed Nov 19, 2003 11:12 am
by microthick
Yes, like above, just add the &nbsp; before your variable.