Jump to content

adding string variables


thefollower

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!!!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.