Professional Web Applications Themes

[PHP] Add a leading zero - PHP Development

Maybe use strlen to check the length of the $i then if it's less than 2 do $i = "0".$i Quick and dirty, but I've done that trick myself in the past. C -----Original Message----- From: Marek Kilimajer [mailto:kilimajerwebglobe.sk] Sent: 24 September 2003 12:43 To: Shaun Cc: [email]php-generallists.php.net[/email] Subject: Re: [PHP] Add a leading zero www.php.net/str_pad Shaun wrote: > Hi, > > How can i add a leading zero to the first result of this loop so that i get > 00, 15, 30, 45? > > <select name="start_date_minute"> > <?php > $i = 0; > while ($i <= 45){ ...

  1. #1

    Default RE: [PHP] Add a leading zero

    Maybe use strlen to check the length of the $i then if it's less than 2 do
    $i = "0".$i

    Quick and dirty, but I've done that trick myself in the past.

    C

    -----Original Message-----
    From: Marek Kilimajer [mailto:kilimajerwebglobe.sk]
    Sent: 24 September 2003 12:43
    To: Shaun
    Cc: [email]php-generallists.php.net[/email]
    Subject: Re: [PHP] Add a leading zero


    www.php.net/str_pad

    Shaun wrote:
    > Hi,
    >
    > How can i add a leading zero to the first result of this loop so that i
    get
    > 00, 15, 30, 45?
    >
    > <select name="start_date_minute">
    > <?php
    > $i = 0;
    > while ($i <= 45){
    > echo '<option value="'.$i.'">'.$i.'</option>';
    > $i+=15;
    > }
    > ?>
    >
    > Thanks for your help
    >
    --
    PHP General Mailing List (http://www.php.net/)
    To unsubscribe, visit: http://www.php.net/unsub.php

    If you are not the intended recipient of this e-mail, please preserve the
    confidentiality of it and advise the sender immediately of any error in
    transmission. Any disclosure, copying, distribution or action taken, or
    omitted to be taken, by an unauthorised recipient in reliance upon the
    contents of this e-mail is prohibited. Somerfield cannot accept liability
    for any damage which you may sustain as a result of software viruses so
    please carry out your own virus checks before opening an attachment. In
    replying to this e-mail you are granting the right for that reply to be
    forwarded to any other individual within the business and also to be read by
    others. Any views expressed by an individual within this message do not
    necessarily reflect the views of Somerfield. Somerfield reserves the right
    to intercept, monitor and record communications for lawful business
    purposes.
    Chris Neale Guest

  2. #2

    Default RE: [PHP] Add a leading zero

    Duh....

    Sorry didn't realise I was replying to a reply to the original message. And
    to add insult to injury str_pad looks like it does the job a lot better...

    C

    -----Original Message-----
    From: Marek Kilimajer [mailto:kilimajerwebglobe.sk]
    Sent: 24 September 2003 12:43
    To: Shaun
    Cc: [email]php-generallists.php.net[/email]
    Subject: Re: [PHP] Add a leading zero


    www.php.net/str_pad

    Shaun wrote:
    > Hi,
    >
    > How can i add a leading zero to the first result of this loop so that i
    get
    > 00, 15, 30, 45?
    >
    > <select name="start_date_minute">
    > <?php
    > $i = 0;
    > while ($i <= 45){
    > echo '<option value="'.$i.'">'.$i.'</option>';
    > $i+=15;
    > }
    > ?>
    >
    > Thanks for your help
    >
    --
    PHP General Mailing List (http://www.php.net/)
    To unsubscribe, visit: http://www.php.net/unsub.php

    If you are not the intended recipient of this e-mail, please preserve the
    confidentiality of it and advise the sender immediately of any error in
    transmission. Any disclosure, copying, distribution or action taken, or
    omitted to be taken, by an unauthorised recipient in reliance upon the
    contents of this e-mail is prohibited. Somerfield cannot accept liability
    for any damage which you may sustain as a result of software viruses so
    please carry out your own virus checks before opening an attachment. In
    replying to this e-mail you are granting the right for that reply to be
    forwarded to any other individual within the business and also to be read by
    others. Any views expressed by an individual within this message do not
    necessarily reflect the views of Somerfield. Somerfield reserves the right
    to intercept, monitor and record communications for lawful business
    purposes.
    Chris Neale Guest

Similar Threads

  1. Question Tracing and Leading
    By Unregistered in forum Brainstorming Area
    Replies: 0
    Last Post: September 11th, 08:06 AM
  2. extra leading
    By Dakota_Keene@adobeforums.com in forum Adobe Indesign Windows
    Replies: 1
    Last Post: May 12th, 10:29 PM
  3. Leading zeroes
    By Olivier Wirz in forum PERL Beginners
    Replies: 3
    Last Post: January 10th, 09:35 PM
  4. Add a leading zero
    By Shaun in forum PHP Development
    Replies: 2
    Last Post: September 24th, 03:06 PM
  5. Leading 3-D softwares?
    By Sly1211 in forum Macromedia Flash Sitedesign
    Replies: 1
    Last Post: September 22nd, 08:10 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139