--- oldmeatus <[EMAIL PROTECTED]> wrote:
> I am taling values from a form using pop up menus.
> I am taking those values, stringing them together and writing
> to a text document.
> The problem is that I am losing a leading zero in one place but
> not the other.
> I want to hold my leading zeroes.
> What I have
> <option value="01">01</option> for theEvhr
> &
> <option value="01">01</option> for theEvDay
>
> to write the string
> $_POST['theEvDay'].$_POST['theEvhr']
>
> the result is
> 011
> instead of
> 0101
>
> any clues ?
As you know, PHP is loosely typed. This means that you don't have to declare
variables and
identify their type and initial value. If you have a numeric value in a string
and perform an
arithmetic operation, PHP will convert it to a number (float or int). I would
guess that somehow
your second variable is being processed as a number at some point.
The sprintf() function has very good formatting options which may help in this
case. For example,
you want an integer number to always be two digits and have leading zeros so
you could use:
$num = sprintf("%02d", $num);
If you concatenate this sort of output you should preserve any leading zeros.
Sometimes it is not the best choice to let PHP do what it wants with your
values, you can have odd
surprises here and there.
Some of the variations can be influenced by the operating system, web server
and version, and the
version of PHP being used. It is usually a good idea to provide this
information in your question
so we don't have to ask for clarification.
James
James D. Keeline
http://www.Keeline.com http://www.Keeline.com/articles
http://Stratemeyer.org http://www.Keeline.com/TSCollection
http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Fall Semester Begins Sep 7 -- New Classes Start Every Few Weeks.
Spring Semester Begins in late January. Two new class topics.
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/