SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: Specify Tab \t

  1. #1
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Do you know a way to specify how many spaces can \t jump?
    And is there a way to know how many space it jumps?
    Since strlen("\t")=1, so I think \t is a control char rather just some spaces
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2000
    Location
    Allentown PA
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    \t is just a regular tab and not directly mapped to a certain amount of spaces... unless you compare it alongside of spaces

    PHP Code:
    echo "<pre>\\\\\\n";
    echo 
    "123456789\\\\\\n\\\\\\t"."end\\\\\\n";
    echo 
    "</pre>\\\\\\n"
    Should work unless I made a typo

  3. #3
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought that there was a way that you could specify how many spaces value a tab is somewhere in the windows files.

    I'm not sure how, but if anyone does, then tell us.

    Peter

  4. #4
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ed, what the purpose of your example? I only see that you use a tab after a bunch of number

    Pete, I don't know what you mean but I'm programming in PHP (non-Windows related)
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  5. #5
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, But i know you can change the value of a tab in windows. So a tab can look different to everyone. Luckily most peopl don't know how to change the tab value.

    Peter

  6. #6
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are talking about formating your output, then you can format it more precisely than by just inserting the tab character \t in your string. Using printf or sprintf you can format the width of a field, whether to left or right align and what fill space to user (default is blank). But don't ask me how, I just know you can.

    BTW, the manual is pretty poor regarding the formating features of printf and sprintf. A topic for a webmasterbase.com article perhaps?

  7. #7
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, that what I ended up with, using sprintf.
    But \t would just be much simpler
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  8. #8
    SitePoint Enthusiast
    Join Date
    Nov 2000
    Location
    Allentown PA
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ed, what the purpose of your example? I only see that you use a tab after a bunch of number
    It would print something like this out:
    Code:
    123456789
    	end
    It's in a monospace font (the <pre>'s), so look for the number above the table to see how large the tab stop is set to.

    Of course, (s)printf is much better as was said.

  9. #9
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    BTW, the manual is pretty poor regarding the formating features of printf and sprintf. A topic for a webmasterbase.com article perhaps?
    Good call! I agree -- every book, article, and manual I've read about this has been pretty poor. I'm bucking to get a good description in WROX's "Professional PHP4" (which I'm currently helping to edit), but in the meantime this is being added to my list of ideas for Tech Times articles!
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •