By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,827 Members | 1,279 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,827 IT Pros & Developers. It's quick & easy.

Multiplying string

P: n/a
Well, in a line of a website i want to get to columns like;

something [itssize]
sth [itssize]
othersth [itssize]
etc.

note the visual attractiveness ;)
first column is made up of strings of different lengths but I'd like second
column to be in nice order ( each "[" under another and so on )
In HTMlL code this spaces between the end of the name and "[" need tto be
filled with "&nbsp". I know ho many spaces is needed but what to write in
PHP code to make it multiply those &nbsp to the required value ?

example which is wrong ofcourse but make you understand me:

echo ("something <? $spaces * &nbsp ?>[itssize]");
Anybody ?


Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
lecichy wrote:
I know ho many spaces is needed but what to write in
PHP code to make it multiply those &nbsp to the required value ?


Use tables...

<TABLE>
<TR><TD>AA</TD><TD>[Blah]</TD></TR>
<TR><TD>BBBB</TD><TD>[Blob]</TD></TR>
<TR><TD>CCCCC</TD><TD>[Black]</TD></TR>
</TABLE>

--
Spam:newsgroup(at)cr*********@verisign-sux-klj.com
EMail:<0110001100101110011000100111010101110010011 010110
11001010100000001100011011100100110000101111010011 011100
11000010111001000101110011000110110111101101101001 00000>
Jul 17 '05 #2

P: n/a
127.0.0.1 wrote:
lecichy wrote:
I know ho many spaces is needed but what to write in
PHP code to make it multiply those &nbsp to the required value ?


Use tables...


Or, if you want to use plain text outoupt, look into printf, it can do all
sorts of wonderful formatting goodness.

Don't forget to use <pre> tags if putting plain text into HTML though!

Have a good weekend,

Ian P. Christian
Jul 17 '05 #3

P: n/a
Ian P. Christian wrote:
127.0.0.1 wrote:

lecichy wrote:

I know ho many spaces is needed but what to write in
PHP code to make it multiply those &nbsp to the required value ?


Use tables...

Or, if you want to use plain text outoupt, look into printf, it can do all
sorts of wonderful formatting goodness.

Don't forget to use <pre> tags if putting plain text into HTML though!


And even add <xmp> ... </xmp> if you output html code inside the plain text.

regards

timo

Jul 17 '05 #4

P: n/a
I noticed that Message-ID: <bm**********@atlantis.news.tpi.pl> from
lecichy contained the following:
example which is wrong ofcourse but make you understand me:

echo ("something <? $spaces * &nbsp ?>[itssize]");


It's really not a good idea to line stuff up using spaces unless you are
using a fixed pitch font. The user may be looking at your site with a
completely different font.

However the way you would do it is to calculate the number of spaces
required and then :
$i=0
while($i<$num_spaces){
$spaces.="&nbsp;";
$i++
}

But I'd use tables. It is, after all, tabular data.

that many times.

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #5

P: n/a
Geoff Berrow wrote:
I noticed that Message-ID: <bm**********@atlantis.news.tpi.pl> from
lecichy contained the following:

example which is wrong ofcourse but make you understand me:

echo ("something <? $spaces * &nbsp ?>[itssize]");

You may wan to check out the manual for the command str_repeat()
to complete your task
However the way you would do it is to calculate the number of spaces
required and then :
$i=0
while($i<$num_spaces){
$spaces.="&nbsp;";
$i++
}


doing such thing is not a very good idea as long as there is str_repeat().

kind regards

timo

Jul 17 '05 #6

P: n/a
I noticed that Message-ID: <bm*************@news.t-online.com> from Timo
Henke contained the following:
doing such thing is not a very good idea as long as there is str_repeat().


Oops, forgot about that one.

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.