displaying white spaces in table cell

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yaron
Forum Contributor
Posts: 157
Joined: Fri Aug 22, 2003 8:40 am

displaying white spaces in table cell

Post 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?
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post 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.
Last edited by Nay on Wed Nov 19, 2003 7:39 am, edited 1 time in total.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Are you doing this in order to pad the cell? Or for another reason?

Mac
User avatar
igoy
Forum Contributor
Posts: 203
Joined: Fri May 02, 2003 11:57 pm
Location: India
Contact:

Post 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..
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Yes, like above, just add the &nbsp; before your variable.
Post Reply