Jump to content

Recommended Posts

I have a line where by two variables have numbers but i can't put them together, how is this done?

 

$Multiply = 0.000

$Input = 45;

 

Then i want them two, to be put together so one variable will show the string as:

0.00045

 

Im not looking for maths here just a way to string them together..

Link to comment
https://forums.phpfreaks.com/topic/81061-adding-string-variables/
Share on other sites

moreover, that just equals zero.  To get .00045, you need to multiply 45 x .00001 :D

 

 

if you just want to put the two variables together, just make sure there arent two decimal places either.

 

$answer = $multiply.$input;

 

also make sure your variables are all the same case, i.e. $Multiply isn't the same as $multiply

For starters, they are not strings.

 

php defaults to numeric? If so that is pain in the butt!!!

 

tommyboy.. unfortionutely your idea didn't quite produce what i was hoping for..

 

$Multiply = 0.00;
$Input = 6;

Echo $Answer = $Multiply.$Input;

 

The result gave : 06

Instead of 0.006

 

Hope you can help.

It defaults to the type of value the variable equals.  If you dont put "quotes" around the number, then it sets to a numeric type.  If you put "quotes" around a number, it sets it to a string.

 

For starters, they are not strings.

 

php defaults to numeric? If so that is pain in the butt!!!

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.