Multiplying string – PHP

  php

Q(Question):

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 ?

A(Answer):

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>

A(Answer):

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

A(Answer):

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

A(Answer):

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/

A(Answer):

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

A(Answer):

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/

LEAVE A COMMENT