Multiplying string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lecichy

    Multiplying string

    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 ?




  • 127.0.0.1

    #2
    Re: Multiplying string

    lecichy wrote:
    [color=blue]
    > I know ho many spaces is needed but what to write in
    > PHP code to make it multiply those &nbsp to the required value ?[/color]

    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)craznar.com@ verisign-sux-klj.com
    EMail:<01100011 001011100110001 001110101011100 10011010110
    110010101000000 011000110111001 001100001011110 10011011100
    110000101110010 001011100110001 101101111011011 0100100000>

    Comment

    • Ian P. Christian

      #3
      Re: Multiplying string

      127.0.0.1 wrote:
      [color=blue]
      > lecichy wrote:
      >[color=green]
      >> I know ho many spaces is needed but what to write in
      >> PHP code to make it multiply those &nbsp to the required value ?[/color]
      >
      > Use tables...[/color]

      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

      Comment

      • Timo Henke

        #4
        Re: Multiplying string

        Ian P. Christian wrote:
        [color=blue]
        > 127.0.0.1 wrote:
        >
        >[color=green]
        >>lecichy wrote:
        >>
        >>[color=darkred]
        >>>I know ho many spaces is needed but what to write in
        >>>PHP code to make it multiply those &nbsp to the required value ?[/color]
        >>
        >>Use tables...[/color]
        >
        >
        > 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![/color]

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

        regards

        timo

        Comment

        • Geoff Berrow

          #5
          Re: Multiplying string

          I noticed that Message-ID: <bmq3g9$449$1@a tlantis.news.tp i.pl> from
          lecichy contained the following:
          [color=blue]
          >example which is wrong ofcourse but make you understand me:
          >
          >echo ("something <? $spaces * &nbsp ?>[itssize]");[/color]

          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_s paces){
          $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/

          Comment

          • Timo Henke

            #6
            Re: Multiplying string

            Geoff Berrow wrote:
            [color=blue]
            > I noticed that Message-ID: <bmq3g9$449$1@a tlantis.news.tp i.pl> from
            > lecichy contained the following:
            >
            >[color=green]
            >>example which is wrong ofcourse but make you understand me:
            >>
            >>echo ("something <? $spaces * &nbsp ?>[itssize]");[/color][/color]

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

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

            kind regards

            timo

            Comment

            • Geoff Berrow

              #7
              Re: Multiplying string

              I noticed that Message-ID: <bmrau7$o7j$01$ 1@news.t-online.com> from Timo
              Henke contained the following:
              [color=blue]
              >doing such thing is not a very good idea as long as there is str_repeat().[/color]

              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/

              Comment

              Working...